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

delete files that are no longer needed #30

Open
luerhard opened this issue May 20, 2020 · 3 comments
Open

delete files that are no longer needed #30

luerhard opened this issue May 20, 2020 · 3 comments

Comments

@luerhard
Copy link

It would be supernice, if there was a way to automatically remove files (and directories) that are leftover from tests that do not exist anymore.
Tests are renamed regularly and after that you (or at least I) have a lot of leftover datafiles that I need to remove manually.

@nicoddemus
Copy link
Member

Hi @luerhard,

Thanks for the suggestion!

I've felt this need myself in the past, but there are a few details that complicate things:

  1. The data directories might contain files other than the ones handled by pytest-regressions, so it is not really safe for us to remove anything there, I believe.
  2. The data directory is managed by pytest-datadir, so my impression is that it would need some sort of similar feature in there, that might overlap here (for example, delete data_ directories which don't have an associated test_ file).

Those are my thoughts, but feel free to suggest solutions if you come up with anything. 👍

@luerhard
Copy link
Author

Hi @nicoddemus, thanks for the reply !
A few thoughts on that:
I am not really sure why someone would store any files other than pytest-regressions data files in those folders. Is there any good reason for this?
If there is, I see two possibilities to handle that:

  • either one has to track all created files in a .pytest_reg file or database or something similar
  • or we could hide the data_ directories as .data_ directories to point out that nobody should store anything else inside apart from the test-data-files.

@tovrstra
Copy link
Contributor

This would be an interesting feature, but other tests using pytest-datadir use files in the same data_* directory. For example:

def test_read_module(datadir):
    contents = (datadir / 'spam.txt').read_text()
    assert contents == 'eggs\n'

def test_data(data_regression):
    data = {"foo": 1}
    data_regression.check(data)

That makes automatic cleaning potentially dangerous.

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

3 participants