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

Exception no attribute 'start_time' if first test is skipped (Py v3.12) #286

Closed
mwhavens opened this issue Jul 26, 2024 · 1 comment
Closed

Comments

@mwhavens
Copy link

When using Python v3.12, if the first test (alphabetically) is skipped, running tests will fail the exception:
AttributeError: '_XMLTestResult' object has no attribute 'start_time'. Did you mean: 'stop_time'?

at the following line:

self.test_result.stop_time - self.test_result.start_time

Tests run order defaults to alphabetically so this can be reproduced using the example in doc and changing the following line:
def test_skipped(self): --> def test_a_skipped(self):

I'm not sure why it works on the older Python versions and not on the newer ones, but the root issue appears to be in the later versions of python if the test is skipped the 'start_time' attribute is never created for the test_result, so when test_finished is called, it assumes that there will always be a start_time attribute on the test_result.

@mwhavens
Copy link
Author

After more investigation it looks like this is due to a bug in cpython 3.12 (113267). So I'm fine closing this issue.

Maybe it's worth adding a try/catch to avoid the assumption that startTest will always have been called prior to stopTest, but it may also not be worth the effort as this bug has been fixed in later versions of Python (v3.12.2+).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant