-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Should tmpdir clean up after itself? #543
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
Comments
Original comment by Jurko Gospodnetić (BitBucket: jurko, GitHub: jurko): I think pytest already does that. It just keeps the temporary test data around for the last few (5?) test runs, but all the ones before that are removed automatically. I haven't checked the source code, but I think that's how pytest behaves for me - Windows 7 installation. IMO, retaining the temporary test data for the last few test runs is extremely useful when you need to debug a specific test failure. Just my 2 cents worth... Best regards, |
I get that some people would prefer to keep some old test run data around. However frequently I have big test data and would like to have it cleaned up (particularly if the tests all pass). Is there a way for one to force cleanup after a run? |
Currently not, but it is easy to add a new [pytest]
tmpdir_keep=0 Currently the default is |
my pytest version is 4.3.1 but not work
this is the content in my pytest.ini file:
this is the test code: CONTENT = "content"
def test_create_file(tmp_path):
print('tmp_path"', tmp_path)
d = tmp_path / "sub"
d.mkdir()
p = d / "hello.txt"
p.write_text(CONTENT)
assert p.read_text() == CONTENT
assert len(list(tmp_path.iterdir())) == 1
assert 0 |
Hi @scottming, The |
Should these details -- that |
@lazarillo It's documented here: https://docs.pytest.org/en/stable/tmpdir.html#the-default-base-temporary-directory |
Thanks, @The-Compiler ! I read that section, but I guess I did not read carefully enough, as I did not notice the
sentence. |
pytest intentionally keeps around a limited number of the previous test temporary directories [1]. This is generally OK, but in our tests that generate initrds, we create a few very large files (both the initrd and kernel in a few copies), which quickly adds up. I had a particularly large initrd (because of some mkosi-initrd shenanigans), and I unded up with dozens of gigabytes of temporary files from the tests. Let's just nuke the dirs where we write kernel data. [1] pytest-dev/pytest#543
pytest intentionally keeps around a limited number of the previous test temporary directories [1]. This is generally OK, but in our tests that generate initrds, we create a few very large files (both the initrd and kernel in a few copies), which quickly adds up. I had a particularly large initrd (because of some mkosi-initrd shenanigans), and I unded up with dozens of gigabytes of temporary files from the tests. Let's just nuke the dirs where we write kernel data. [1] pytest-dev/pytest#543 (cherry picked from commit ef0a69e)
pytest intentionally keeps around a limited number of the previous test temporary directories [1]. This is generally OK, but in our tests that generate initrds, we create a few very large files (both the initrd and kernel in a few copies), which quickly adds up. I had a particularly large initrd (because of some mkosi-initrd shenanigans), and I unded up with dozens of gigabytes of temporary files from the tests. Let's just nuke the dirs where we write kernel data. [1] pytest-dev/pytest#543 (cherry picked from commit ef0a69e) (cherry picked from commit d93341f)
pytest intentionally keeps around a limited number of the previous test temporary directories [1]. This is generally OK, but in our tests that generate initrds, we create a few very large files (both the initrd and kernel in a few copies), which quickly adds up. I had a particularly large initrd (because of some mkosi-initrd shenanigans), and I unded up with dozens of gigabytes of temporary files from the tests. Let's just nuke the dirs where we write kernel data. [1] pytest-dev/pytest#543 (cherry picked from commit ef0a69e) (cherry picked from commit d93341f)
pytest intentionally keeps around a limited number of the previous test temporary directories [1]. This is generally OK, but in our tests that generate initrds, we create a few very large files (both the initrd and kernel in a few copies), which quickly adds up. I had a particularly large initrd (because of some mkosi-initrd shenanigans), and I unded up with dozens of gigabytes of temporary files from the tests. Let's just nuke the dirs where we write kernel data. [1] pytest-dev/pytest#543 (cherry picked from commit ef0a69e) (cherry picked from commit d93341f)
pytest intentionally keeps around a limited number of the previous test temporary directories [1]. This is generally OK, but in our tests that generate initrds, we create a few very large files (both the initrd and kernel in a few copies), which quickly adds up. I had a particularly large initrd (because of some mkosi-initrd shenanigans), and I unded up with dozens of gigabytes of temporary files from the tests. Let's just nuke the dirs where we write kernel data. [1] pytest-dev/pytest#543 (cherry picked from commit ef0a69e) (cherry picked from commit d93341f)
pytest intentionally keeps around a limited number of the previous test temporary directories [1]. This is generally OK, but in our tests that generate initrds, we create a few very large files (both the initrd and kernel in a few copies), which quickly adds up. I had a particularly large initrd (because of some mkosi-initrd shenanigans), and I unded up with dozens of gigabytes of temporary files from the tests. Let's just nuke the dirs where we write kernel data. [1] pytest-dev/pytest#543 (cherry picked from commit ef0a69e) (cherry picked from commit d93341f)
Adding comment because this is coming up in related Google searches. There are two options which are now used to configure tmpdir retention:
See retention reference and the issue which planned these updates. |
Originally reported by: Christian Theune (BitBucket: ctheune, GitHub: ctheune)
We noticed that tmpdir isn't cleaning up after itself.
Is there a reason why not? The docs don't mention it. Otherwise: I'd be happy to provide a patch to make tmpdir clean up after itself.
The text was updated successfully, but these errors were encountered: