mirror of
https://github.com/python/cpython.git
synced 2024-12-23 08:44:20 +08: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
@ -1,4 +1,3 @@
|
||||
import datetime
|
||||
import faulthandler
|
||||
import locale
|
||||
import os
|
||||
@ -150,9 +149,12 @@ class Regrtest:
|
||||
|
||||
# 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]
|
||||
|
||||
|
@ -9,8 +9,6 @@ import time
|
||||
import traceback
|
||||
import unittest
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
class RegressionTestResult(unittest.TextTestResult):
|
||||
separator1 = '=' * 70 + '\n'
|
||||
separator2 = '-' * 70 + '\n'
|
||||
@ -21,6 +19,7 @@ class RegressionTestResult(unittest.TextTestResult):
|
||||
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(' '))
|
||||
|
Loading…
Reference in New Issue
Block a user