-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
unittest instance objects exist for the lifetime of the py.test run #1649
Comments
I believe that it would be sufficient to set the TestCaseFunction instance's _testcase and _obj attributes to None after all cleanup is complete. |
See also the report here: http://stackoverflow.com/questions/20900380/py-test-excessive-memory-usage-with-large-number-of-tests |
Feel like trying to do a PR? |
Yeah, I'd like to. I have some testing to do with my idea, though - it seems to cause some problems with our test set. |
…ev#1649). Fix pytest-dev#1649 Users of unittest style TestCases will create expensive objects in setUp. We should clean up TestCase instances that are lying around so that they don't fill up memory.
Clean up unittest TestCase objects after tests are complete (#1649).
unittest.TestCase instance objects are never cleaned up - the py.test unittest module retains references to them for the whole of the py.test run. In my case, this can cause problems because the unittest.TestCase instance objects can have large objects associated with them. I believe that people writing unittest-based tests expect that their objects will be cleaned up after test execution.
I've seen this on Linux/Darwin/Windows
pytest==2.8.7
pytest-cov==2.2.1
pytest-faulthandler==1.3.0
pytest-xdist==1.14
Example:
Given this test:
The memory allocated for larg_object will be in use for the whole py.test run, even after it is done with this test.
The text was updated successfully, but these errors were encountered: