test: Custom main() function
It's not as full featured as unittest.main(), but this will allow us to add custom command line arguments.
This commit is contained in:
parent
ed8a21a627
commit
29cf2c4e8c
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@ -56,4 +57,17 @@ class ComposerTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
unittest.main(verbosity=2)
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("tests", nargs="*", help="List of tests modules, classes, and methods")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
module = __import__("__main__")
|
||||||
|
|
||||||
|
if args.tests:
|
||||||
|
tests = unittest.defaultTestLoader.loadTestsFromNames(args.tests, module)
|
||||||
|
else:
|
||||||
|
tests = unittest.defaultTestLoader.loadTestsFromModule(module)
|
||||||
|
|
||||||
|
runner = unittest.TextTestRunner(verbosity=2)
|
||||||
|
result = runner.run(tests)
|
||||||
|
sys.exit(not result.wasSuccessful())
|
||||||
|
Loading…
Reference in New Issue
Block a user