Davin Potts added the comment:

Though this issue is specifically concerned with runpy APIs and their impact 
especially in running unittest test scripts, it's worth commenting here for 
people who need a workaround in the short term:  code such as that shared in 
http://stackoverflow.com/q/41892297/1878788 can be made to run happily by 
creating a second script which imports the first and simply runs the test(s) 
from there.

In the specific case of the 'forkiter.py' from 
http://stackoverflow.com/q/41892297/1878788, one would create a 
'run_my_tests.py' with the contents:

from forkiter import main

if __name__ == "__main__":
    exit(main())





Now this invocation of cProfile runs happily because pickle is able to see the 
module where all the needed classes/functions were defined:
python3.6 -m cProfile -o forkiter.prof ./run_my_tests.py

----------
nosy: +davin

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

Reply via email to