May 15, 2012, 1:04:45 AM5/15/12
Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message as abuse
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
I've discovered why renamed a .py file, which a test_some.py file is dependent upon, doesn't break the test.
Typical example: rename pytddmon.py while pytddmon is running on its own tests. All tests are dependent on pytddmon.py (through import pytddmon statements), but renaming pytddmon.py to strange.py DOES NOT BREAK THE TESTS.
While in some older versions of pytddmon, the change isn't even detected, that is not the case with the new Monitor-based pytddmon. But still the tests does not break! So the rename is detected as a change, but 17/17 green tests.
It just bewildered med the other night, how that was possible at all. But then I got it: Python looks not only on .py files, but also on .pyc files! That is, if you rename pytddmon.py, Python doesn't find it. But it finds pytddmon.pyc instead.
This probably is a feature of Python, so that you can distribute your Python application without source code if you want to, and it will work seamlessly.
But it does pose a problem to pytddmon that I'd like to solve. Some ad-hoc thoughts:
1) pytddmon could physically *delete* all .pyc files for every .py file it finds. That solution seems brutal and I'm not fond at all in deleting files automagically, even though .pyc files are output files and not source files
2) maybe there is some flag to unittest and/or python that could disable this "run-.pycs-when-.py-not-found"-feature?
3) list might have some beautiful idea how to solve this.