Carl Meyer <c...@dirtcircle.com> added the comment:

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?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11591>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to