Skip to content

bpo-41718: libregrtest avoids importing datetime #24985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import faulthandler
import locale
import os
Expand Down Expand Up @@ -150,9 +149,12 @@ def log(self, line=''):

# add the timestamp prefix: "0:01:05 "
test_time = time.monotonic() - self.start_time
test_time = datetime.timedelta(seconds=int(test_time))
line = f"{test_time} {line}"

mins, secs = divmod(int(test_time), 60)
hours, mins = divmod(mins, 60)
test_time = "%d:%02d:%02d" % (hours, mins, secs)

line = f"{test_time} {line}"
if empty:
line = line[:-1]

Expand Down
3 changes: 1 addition & 2 deletions Lib/test/support/testresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import traceback
import unittest

from datetime import datetime

class RegressionTestResult(unittest.TextTestResult):
separator1 = '=' * 70 + '\n'
separator2 = '-' * 70 + '\n'
Expand All @@ -21,6 +19,7 @@ def __init__(self, stream, descriptions, verbosity):
self.buffer = True
if self.USE_XML:
from xml.etree import ElementTree as ET
from datetime import datetime
self.__ET = ET
self.__suite = ET.Element('testsuite')
self.__suite.set('start', datetime.utcnow().isoformat(' '))
Expand Down