]> gitweb.michael.orlitzky.com - dunshire.git/blob - test/__main__.py
Build looping into the test suite and make doctests optional.
[dunshire.git] / test / __main__.py
1 #!/usr/bin/env python
2 """
3 An implementation of __main__() that allows us to "run this module."
4 """
5 from sys import argv
6
7 from test import build_suite, run_suite
8
9 # We take two command-line arguments. The first enables you to turn
10 # off the doctests, which are deterministic. The second tells us to
11 # repeat the test suite indefinitely rather than return the result
12 # of running it once. The flags usually occur together so that we
13 # don't waste time running the doctests in a loop.
14 doctests = True
15 loop = False
16
17 if "--no-doctests" in argv:
18 doctests = False
19
20 if "--loop" in argv:
21 loop = True
22
23 # Running the test suite clobbers it! And deepcopy() doesn't work on a
24 # suite that contains doctests! ARRRGRRGRRGRHG!!!!!! You're all idiots.
25 result = run_suite(build_suite(doctests))
26
27 if result.wasSuccessful() and not loop:
28 exit(0)
29
30 if loop:
31 while(result.wasSuccessful()):
32 result = run_suite(build_suite(doctests))
33
34 exit(1)