Skip to content

Add an environment variable to keep temporary directories when testing #5676

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

Merged
merged 3 commits into from
Jul 30, 2018

Conversation

pfmoore
Copy link
Member

@pfmoore pfmoore commented Jul 30, 2018

This is a bit of a hack, but cleanup of temporary directories when trying to test locally is a real pain, and this gives a way out without needing to modify conftest.py.

@pypa/pip-committers Does this seem like a reasonable addition, or is it too much of a hack?

@pfmoore pfmoore added the skip news Does not need a NEWS file entry (eg: trivial changes) label Jul 30, 2018
@dstufft
Copy link
Member

dstufft commented Jul 30, 2018

It seems fine to me. Keeping the last N runs of temp files is actually the default behavior of py.test... we just override it because I think a full test run is something like 12GB of temporary files for us.

@pfmoore
Copy link
Member Author

pfmoore commented Jul 30, 2018

Yes, ideally it should be some sort of command line flag (so people don't get surprised by forgetting to delete the env var) but IMO it's too niche a need to be worth that extra complexity.

I never run the full test suite locally anyway, it takes way too long. But running one test to iterate on fixes for a CI failure does save time.

@dstufft
Copy link
Member

dstufft commented Jul 30, 2018

If you want to add a CLI option, it's not very hard, you just add:

def pytest_addoption(parser):
    parser.addoption(
        "--cmdopt", action="store", default="type1", help="my option: type1 or type2"
    )

to conftest.py, then you can access it in the fixture by adding a request parameter to the function and accessing it like so:

@pytest.fixture
def cmdopt(request):
    return request.config.getoption("--cmdopt")

See more details at https://docs.pytest.org/en/latest/example/simple.html#pass-different-values-to-a-test-function-depending-on-command-line-options.

Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do run the entire test suite locally regularly (it takes less time than Travis, due to more cores/threads).

This seems reasonable to me.

@pfmoore
Copy link
Member Author

pfmoore commented Jul 30, 2018

@dstufft Thanks for that - it is indeed nice & easy to add a command line option, so I've done that.

@pradyunsg
Copy link
Member

That said, @dstufft's suggestion of making this a CLI flag would also work.

Personally, I doubt I'd use this much and even when I do, both would work just fine so I don't feel strongly here.

@pradyunsg
Copy link
Member

@pfmoore Nice timing. :P

@pfmoore pfmoore closed this Jul 30, 2018
@pfmoore pfmoore reopened this Jul 30, 2018
@pfmoore
Copy link
Member Author

pfmoore commented Jul 30, 2018

Pinging appveyor

@pfmoore pfmoore merged commit db12733 into pypa:master Jul 30, 2018
@pfmoore pfmoore deleted the keep_tmpdir branch July 30, 2018 21:36
@lock
Copy link

lock bot commented Jun 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation skip news Does not need a NEWS file entry (eg: trivial changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants