This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author carljm
Recipients carljm, eric.araujo
Date 2011-03-17.22:35:09
SpamBayes Score 2.1649349e-14
Marked as misclassified No
Message-id <1300401309.9.0.891643547732.issue11591@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2011-03-17 22:35:09carljmsetrecipients: + carljm, eric.araujo
2011-03-17 22:35:09carljmsetmessageid: <1300401309.9.0.891643547732.issue11591@psf.upfronthosting.co.za>
2011-03-17 22:35:09carljmlinkissue11591 messages
2011-03-17 22:35:09carljmcreate