Skip to content

Remove stale bytecode files #590

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

Closed
pytestbot opened this issue Sep 13, 2014 · 8 comments
Closed

Remove stale bytecode files #590

pytestbot opened this issue Sep 13, 2014 · 8 comments
Labels
type: enhancement new feature or API change, should be merged into features branch

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Wolfgang Schnerring (BitBucket: wosc, GitHub: wosc)


The situation is rather rare (when switching between branches for example) that you get obsolete .pyc/.pyo files, i.e. without corresponding .py files, but when it occurs it can lead to obscure and really hard to detect problems. So it might be a worthwile feature to clean those up automatically (zope.testrunner does this for example).


@pytestbot
Copy link
Contributor Author

Original comment by Michael Howitz (BitBucket: icemac, GitHub: icemac):


We developed a plug-in which removes stale byte code files: https://pypi.python.org/pypi/pytest-remove-stale-bytecode

So the ticket an be considered as solved.

@pytestbot
Copy link
Contributor Author

Original comment by Floris Bruynooghe (BitBucket: flub, GitHub: flub):


Thanks, a plugin seems like a nice solution. If it turns out very popular it can always be included in the core.

@pytestbot
Copy link
Contributor Author

Original comment by BitBucket: faassen, GitHub: faassen:


I just came here to report that this would be a useful feature to me too.

Is there a good reason for py.test not to do this by default?

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


So far i didn't see it as a core responsibility of a testing tool to clean up pyc files. Personally i use py.cleanup from the pycmd package and i think the plugin posted here is also a good idea. Maybe it could just be named "pytest-nopyc" though to make it easier to install out of the head :)

@pytestbot
Copy link
Contributor Author

Original comment by BitBucket: faassen, GitHub: faassen:


The argument for making it the responsibility of the test runner is because it can lead to correctly written tests passing that shouldn't be failing, without warning.

It's tripped me up quite a few times after I started using py.test and it never did with the zope test runner. It sometimes takes a little bit of time to realize what is going on, sometimes after pushing the code, and sometimes until I check out the code again. It's never a huge deal, but it just happened to come up again (in the context of nose, actually) and I figured this time I'd say something. Just that little bit of extra usability that I've come to expect from py.test.

A warning would be an alternative: "this test only works because there's a .pyc file without .py file". Or maybe "stale .pyc files detected".

@pytestbot
Copy link
Contributor Author

Original comment by Markus Unterwaditzer (BitBucket: untitaker, GitHub: untitaker):


I think this behavior should be added to tox instead, because tox already takes precautions like setting the PYTHONHASHSEED.

@pytestbot
Copy link
Contributor Author

Original comment by BitBucket: faassen, GitHub: faassen:


Maybe tox should also do something, but I run into this when I use pytest alone. (with tox I frequently need to nuke the .tox directory to make things go again, but I haven't dug into why this is yet)

@pytestbot
Copy link
Contributor Author

Original comment by Floris Bruynooghe (BitBucket: flub, GitHub: flub):


Is this something that affects both Python 2.x and 3.x or just 2.x? My own quick experimentation makes me think this only affects 2.x.

@pytestbot pytestbot added the type: enhancement new feature or API change, should be merged into features branch label Jun 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

1 participant