Eli Bendersky added the comment:

A question that comes up is how should a module signal to regrtest that it 
needs to be run in a subprocess?

The most natural approach is to have a special attribute set in the module's 
global dict (for example: __REGRTEST_SUBPROCESS__ = True); however, there's a 
slight problem with this approach - regrtest has to import the module to see 
this attribute, and the module may do some work in its top-level code 
(commonly, imports) that already needs to be done within a subprocess.

One solution is to use a different approach, such as a separate file alongside 
the test file (i.e. test_foo.regrtest_subprocess alongside test_foo.py). This 
is quite ugly but "safe".

A different solution is to require modules that want to be executed in a 
subprocess to not do any top-level work; modules can already define a custom 
test_main function that regrtest discovers - we can require for this feature to 
work that modules do all their work through this function, rather than in the 
global scope.

----------
stage: needs patch -> 
type: enhancement -> 

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

Reply via email to