This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author davin
Recipients belopolsky, bli, davin, eric.snow, ezio.melotti, flox, georg.brandl, ncoghlan, serhiy.storchaka, tati_alchueyr
Date 2017-01-30.14:08:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1485785290.55.0.377005994671.issue9914@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2017-01-30 14:08:10davinsetrecipients: + davin, georg.brandl, ncoghlan, belopolsky, ezio.melotti, flox, eric.snow, serhiy.storchaka, tati_alchueyr, bli
2017-01-30 14:08:10davinsetmessageid: <1485785290.55.0.377005994671.issue9914@psf.upfronthosting.co.za>
2017-01-30 14:08:10davinlinkissue9914 messages
2017-01-30 14:08:10davincreate