Message131294
Adding a test is easier said than done. The behavior change here depends on python being run with -S. Currently test_site skips itself if the test suite is run with -S, and if I remove that skip it crashes under -S.
Options as I see it:
1. Declare this one-liner correct by inspection. It doesn't break any existing tests.
2. Add a new test file (test_no_site.py?) that only runs with -S and tests that importing something from site doesn't trigger sys.path additions. This seems like the most reasonable test, but I'm not sure how useful it is, since I doubt most people ever try running the test suite with -S.
3. Make the fix more complicated such that it uses an intermediary variable which can be mocked (unlike sys.flags.no_site, which is read-only), and then add a test which mocks this variable, temporarily removes "site" from sys.modules, tries importing it again, and checks whether main() is called. This creates a complex test which is highly coupled to the implementation in site.py, but would be run under normal conditions (without -S).
Which option do you prefer? |
|
Date |
User |
Action |
Args |
2011-03-17 22:35:09 | carljm | set | recipients:
+ carljm, eric.araujo |
2011-03-17 22:35:09 | carljm | set | messageid: <1300401309.9.0.891643547732.issue11591@psf.upfronthosting.co.za> |
2011-03-17 22:35:09 | carljm | link | issue11591 messages |
2011-03-17 22:35:09 | carljm | create | |
|