I have a bunch of modules and for each module I have a unittest based test. I want to define the main in each module to run its tests, but I get import errors because of import loops (specifically when I use from mymodule import myclass in the test.
I suspect this is a solved problem, so – what should I put in my module’s main to run its corresponding test?
I have a bunch of modules and for each module I have a unittest
Share
If I understand you correctly, you’ve got a file (lets call it mymodule.py) that looks like this:
and a separate file (lets call it mymoduletests.py) that looks something like this:
If you run mymodule.py you get the following result:
However, if you change mymodule.py to this:
and then run it, you get:
Have I understood you correctly?