/ tests.py
tests.py
1 #!/usr/bin/env python 2 """Custom tests runner script for tox and python3""" 3 import random # noseq 4 import sys 5 import unittest 6 7 8 def unittest_discover(): 9 """Explicit test suite creation""" 10 if sys.hexversion >= 0x3000000: 11 from pybitmessage import pathmagic 12 pathmagic.setup() 13 loader = unittest.defaultTestLoader 14 # randomize the order of tests in test cases 15 loader.sortTestMethodsUsing = lambda a, b: random.randint(-1, 1) 16 # pybitmessage symlink disappears on Windows! 17 testsuite = loader.discover('pybitmessage.tests') 18 testsuite.addTests([loader.discover('pybitmessage.pyelliptic')]) 19 20 return testsuite 21 22 23 if __name__ == "__main__": 24 success = unittest.TextTestRunner(verbosity=2).run( 25 unittest_discover()).wasSuccessful() 26 try: 27 from pybitmessage.tests import common 28 except ImportError: 29 checkup = False 30 else: 31 checkup = common.checkup() 32 33 if checkup and not success: 34 print(checkup) 35 36 sys.exit(not success or checkup)