Created
December 13, 2012 06:44
-
-
Save santiycr/4274570 to your computer and use it in GitHub Desktop.
Run python unit tests from a different python script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import test_example | |
unittest.main(module=test_example) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
class myTest(unittest.TestCase): | |
def test_dummy(self): | |
assert True |
thanks for sharing the fix!
If changing sys.argv
is not an option, one can use unittest.TextTestRunner
as described in this StackOverflow answer. IMHO, that's a more convenient way.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This fails if
import_and_run.py
hasmain
function with arguments.To solve that, need to override
sys.argv
. something like: