mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
bpo-41718: libregrtest avoids importing datetime (GH-24985)
* libregrtest reimplements datetime.timedelta.__str__() * support.testresult only imports datetime if USE_XML is true.
This commit is contained in:
parent
30793e81bd
commit
9feae41c4f
2 changed files with 6 additions and 5 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
import datetime
|
|
||||||
import faulthandler
|
import faulthandler
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
|
|
@ -150,9 +149,12 @@ class Regrtest:
|
||||||
|
|
||||||
# add the timestamp prefix: "0:01:05 "
|
# add the timestamp prefix: "0:01:05 "
|
||||||
test_time = time.monotonic() - self.start_time
|
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:
|
if empty:
|
||||||
line = line[:-1]
|
line = line[:-1]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ import time
|
||||||
import traceback
|
import traceback
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
class RegressionTestResult(unittest.TextTestResult):
|
class RegressionTestResult(unittest.TextTestResult):
|
||||||
separator1 = '=' * 70 + '\n'
|
separator1 = '=' * 70 + '\n'
|
||||||
separator2 = '-' * 70 + '\n'
|
separator2 = '-' * 70 + '\n'
|
||||||
|
|
@ -21,6 +19,7 @@ class RegressionTestResult(unittest.TextTestResult):
|
||||||
self.buffer = True
|
self.buffer = True
|
||||||
if self.USE_XML:
|
if self.USE_XML:
|
||||||
from xml.etree import ElementTree as ET
|
from xml.etree import ElementTree as ET
|
||||||
|
from datetime import datetime
|
||||||
self.__ET = ET
|
self.__ET = ET
|
||||||
self.__suite = ET.Element('testsuite')
|
self.__suite = ET.Element('testsuite')
|
||||||
self.__suite.set('start', datetime.utcnow().isoformat(' '))
|
self.__suite.set('start', datetime.utcnow().isoformat(' '))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue