original) (raw)
(I've tried this as an inherent property of regrtest before (to resolveOn Sun, Dec 30, 2012 at 10:46 AM, Benjamin Peterson <benjamin@python.org> wrote:
> 2012/12/29 Eli Bendersky <eliben@gmail.com>:
>> Hi,
>>
>> This came up while investigating some test-order-dependency failures in
>> issue 16076.
>>
>> test___all__ goes over modules that have `__all__` in them and does 'from
>> import *' on them. This leaves a lot of modules in sys.modules,
>> which may interfere with some tests that do fancy things with sys,modules.
>> In particular, the ElementTree tests have trouble with it because they
>> carefully set up the imports to get the C or the Python version of etree
>> (see issues 15083 and 15075).
>>
>> Would it make sense to save the sys.modules state and restore it in
>> test___all__ so that sys.modules isn't affected by this test?
>
> Sounds reasonable to me.
some problems with test\_pydoc), and it didn't work - we have too many
modules with non-local side effects (IIRC, mostly related to the copy
and pickle registries).
Given that it checks the whole standard library, test\_\_\_all\_\_ is
likely to run into the same problem.
This may be a naive question, but why don't we run the tests in separate interpreters? For example with -j we do (which creates all kinds of strange intermittent problems depending on which tests got bundled into the same process). Is this a matter of performance? Because that would help get rid of these dependencies between tests, which would probably save core devs some work and headache.
Hence test.support.import\_fresh\_module - it can ensure you get the
module you want, regardless of the preexisting contents of
sys.modules. (http://docs.python.org/dev/library/test#test.support.import\_fresh\_module)