-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
doctest.DocTestCase fails when run repeatedly #46856
Comments
DocTestCase.tearDown destructively clears its DocTest instance's globs, There's a fix for this in zope.testing's version of doctest, which |
Addendum: This appears to be a regression in r36809 (Python 2.4+). |
Is repeating a test with the same TestCase instance ever safe? It'd be If any of the variables in test.globs are changed by the test (e.g. While the zope change allows tests that have immutable globals or don't |
This is true, but modifying the globals such that subsequent runs of the |
If I create a test case with a command like: test = DocFileSuite('foo.txt', globs={'somelist': [42]}) The doctest isn't doing anything wrong if it modifies somelist. Furthermore, Glyph has said he thinks the current --until-failure |
Well, whether that code is wrong depends on whether your project policy In any case, DocTestCase allowing non-repeatable tests (which i don't |
FWIW, the python testsuite needs repeatable tests, when running in See also r62100, where a DocTestSuite construction had to be moved into |
For the record, this bug also breaks zope.testrunner's --repeat option, if you have any doctests in your test suite that rely on test.globs not going away. |
I've reproduced this on 3.11 as well. The patch here needs to be converted to a GitHub PR and then tested and reviewed. The patch on bpo-9736 has a unit test as well, which should be included (because the pjd's patch doesn't have one). |
I have created a PR that combines the patch here with the patch from bpo-9736. |
After 14 years this bug is finally fixed. Thanks everyone for the patches and discussion. |
Thanks! 😄️ |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: