X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=test%2F__main__.py;h=d4ef145caa663c78d6d4e1891b031b61d56d152b;hb=61befafddd6a40cad46bd15508e4cbda66df35f2;hp=aca4e64ec83a4f944e57ec67117c6d2de74db0db;hpb=d08e0af9bf86e81d4a5b3dbbe38092bacc5edd62;p=dunshire.git diff --git a/test/__main__.py b/test/__main__.py index aca4e64..d4ef145 100755 --- a/test/__main__.py +++ b/test/__main__.py @@ -6,29 +6,44 @@ from sys import argv from test import build_suite, run_suite -# We take two command-line arguments. The first enables you to turn -# off the doctests, which are deterministic. The second tells us to -# repeat the test suite indefinitely rather than return the result -# of running it once. The flags usually occur together so that we -# don't waste time running the doctests in a loop. -doctests = True -loop = False -if "--no-doctests" in argv: - doctests = False +def main(doctests, loop): + """ + The main function for this module. It runs the tests. -if "--loop" in argv: - loop = True + We take two command-line arguments. The first enables you to turn + off the doctests, which are deterministic. The second tells us to + repeat the test suite indefinitely rather than return the result of + running it once. The flags usually occur together so that we don't + waste time running the doctests in a loop. -# Running the test suite clobbers it! And deepcopy() doesn't work on a -# suite that contains doctests! ARRRGRRGRRGRHG!!!!!! You're all idiots. -result = run_suite(build_suite(doctests)) + Parameters + ---------- -if result.wasSuccessful() and not loop: - exit(0) + doctests : bool + Do you want to run the doctests? -if loop: - while(result.wasSuccessful()): - result = run_suite(build_suite(doctests)) + loop : bool + Do you want to loop and rerun the tests indefinitely? -exit(1) + """ + # Running the test suite clobbers it! And deepcopy() doesn't work + # on a suite that contains doctests! ARRRGRRGRRGRHG!!!!!! You're all + # idiots. + result = run_suite(build_suite(doctests)) + + if result.wasSuccessful() and not loop: + return 0 + + if loop: + passed = 0 + while result.wasSuccessful(): + print('Passed: {:d}'.format(passed)) + passed += 1 + result = run_suite(build_suite(doctests)) + + return 1 + + +if __name__ == '__main__': + exit(main(not "--no-doctests" in argv, '--loop' in argv))