Skip to content
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

Address 'addDuration' warnings in python 3.12. #275

Merged
merged 2 commits into from
Dec 5, 2023
Merged
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
17 changes: 17 additions & 0 deletions green/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ def __init__(self, stream, colors):
self.stderr_errput = OrderedDict()
self.stream = stream
self.colors = colors
# The collectedDurations list is new in Python 3.12.
self.collectedDurations = []

def recordStdout(self, test, output):
"""
Expand Down Expand Up @@ -218,6 +220,19 @@ def displayStderr(self, test):
)
del self.stderr_errput[test]

def addDuration(self, test, elapsed):
"""
Called when a test finished running, regardless of its outcome.

New in Python 3.12.

Args:
test: The test case corresponding to the test method.
elapsed: The time represented in seconds, including the
execution of cleanup functions.
"""
self.collectedDurations.append((str(test), elapsed))


class ProtoTestResult(BaseTestResult):
"""
Expand Down Expand Up @@ -247,6 +262,7 @@ def __init__(self, start_callback=None, finalize_callback=None):

def reinitialize(self):
self.shouldStop = False
self.collectedDurations = []
self.errors = []
self.expectedFailures = []
self.failures = []
Expand Down Expand Up @@ -392,6 +408,7 @@ def __init__(self, args, stream):
self.shouldStop = False
self.testsRun = 0
# Individual lists
self.collectedDurations = []
self.errors = []
self.expectedFailures = []
self.failures = []
Expand Down