py.test should kill orphaned pyc files

Create issue
Issue #29 open
Ronny Pfannschmidt created an issue

i just noticed that while shuffling around files and not getting the expected failures till a py.cleanup

Comments (8)

  1. Holger Krekel repo owner
    • changed status to open

    on large sourcetrees this can slow up development so it needs to be enabled by an option ... but it if needs to be manually enabled it is less useful. Pending a solution coming from a more intelligent/configurable filesystem later, what about an import hook that refuses to load anything from a .pyc where no .py is present? And maybe optionally disable the installation of this hook? Sounds useful to me - not sure if it can be done cleanly and robustly considering the python import system complexity.

    On a sidenote, if we more naturally and more quickly drive distributed testing to various sub environments (virtualenv etc.) the issue might vanish - because rsyncing can take care to never transfer pyc files.

  2. Ronny Pfannschmidt reporter

    since py.test -f tracks changes on the tree, it should be able to remove the .pyc which lack a .py file

    collect is another thing that could be enabled to deal with missing .pyc files

    but the import hook sounds valid, too

  3. Benjamin Peterson

    I don't think py.test should ever delete files in a tree. Even if they are likely compiled junk, there's no guarantee that someone is not storing their passwords (or worse) in it. Simply refusing to run tests where only a .pyc file exists is much more optimal behavior.

  4. Ronny Pfannschmidt reporter

    its not about test modules, its about random modules still seemingly working after the py file is in another place already

  5. Holger Krekel repo owner
    • changed milestone to 1.1

    what about issuing a warning at the very end of the test run? ("saw PYC file without source: XYZ.pyc")?

    Dangling pyc files have bitten many people.

  6. Log in to comment