Message196810
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. |
|
Date |
User |
Action |
Args |
2013-09-02 21:43:01 | eli.bendersky | set | recipients:
+ eli.bendersky, ncoghlan, ezio.melotti, serhiy.storchaka |
2013-09-02 21:43:01 | eli.bendersky | set | messageid: <1378158181.84.0.493033868957.issue18906@psf.upfronthosting.co.za> |
2013-09-02 21:43:01 | eli.bendersky | link | issue18906 messages |
2013-09-02 21:43:01 | eli.bendersky | create | |
|