-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
TestResult.stopTest
called when test is skipped, despite TestResult.startTest
not being called
#113267
Comments
TestResult.stopTest
called when test is skipped, despite TestResult.startTest
TestResult.stopTest
called when test is skipped, despite TestResult.startTest
not being called
I am now also seeing failures in PyCharm's unit testing because of this issue. This is starting to be a huge issue. |
I think that it was a wrong change, and not only because it makes |
…in Python 3.12 (pythonGH-106588)" (pythonGH-114470) This reverts commit 8fc0713. (cherry picked from commit ecabff9) Co-authored-by: Serhiy Storchaka <[email protected]>
Thanks, the changes for 3.12.2 seem to fix CleanCut/green#277 |
…in Python 3.12 (python#106588)" (pythonGH-114470) This reverts commit 8fc0713.
…in Python 3.12 (python#106588)" (pythonGH-114470) This reverts commit 8fc0713.
python/cpython#113267 has been fixed.
Branch: refs/heads/main Date: 2024-02-27T20:48:22-08:00 Author: Wesley Barroso Lopes (wesleybl) <[email protected]> Commit: plone/plone.restapi@1771c9c Use last version of Python 3.12 in tests (#1756) python/cpython#113267 has been fixed. Files changed: A news/1740.internal M .github/workflows/tests.yml
Branch: refs/heads/main Date: 2024-02-27T20:48:22-08:00 Author: Wesley Barroso Lopes (wesleybl) <[email protected]> Commit: plone/plone.restapi@1771c9c Use last version of Python 3.12 in tests (#1756) python/cpython#113267 has been fixed. Files changed: A news/1740.internal M .github/workflows/tests.yml
Bug report
Bug description:
Following commit 551aa6ab9419109a80ad53900ad930e9b7f2e40d a bug seems to have been introduced in the
TestCase.run
method.Because the
result.startTest(self)
call was moved inside the try/finally block after the check to see if the test is skipped, theresult.stopTest(self)
call will be made even if the test is skipped andstartTest
is never called.While this does not cause issues with the standard
TestResult
orTextTestResult
classes, it can cause issues with other classes which subclass those and expect every call tostopTest
to be preceded by a call fromstartTest
.Most notably for me, the
unittest-xml-reporting
package, whosestopTest
method uses data initialized instartTest
.Note: Further thinking about this problem, it seems like changing the flow of methods like this was ill thought solution to the problem in the first place, as this might be an unexpected change of behaviour for different libraries. I'm still leaving what I think could be the solution in case I'm wrong on that.
It looks like the fix would seem to be moving the call to
stopTest
in yet another try/finally block right after the call tostartTest
, emulating the same behaviour as previous code while keeping the call tostartTest
after the skip check. The call tostopTestRun
would need to remain where it is asstartTestRun
has already been called at this point.So using the code as found in that commit, something like:
CPython versions tested on:
3.12
Operating systems tested on:
Linux, Windows
Linked PRs
The text was updated successfully, but these errors were encountered: