diff options
| author | James Westby <james.westby@canonical.com> | 2010-06-07 00:20:08 +0100 |
|---|---|---|
| committer | James Westby <james.westby@canonical.com> | 2010-06-07 00:20:08 +0100 |
| commit | 09798f9739047e198544e672ffc7bb5b23128d52 (patch) | |
| tree | b9e66c8f1b2b1fd92765f76c9337d9f6a68a049e /python | |
| parent | 15319ea5c759d6128845035b356092106ad95864 (diff) | |
| download | subunit-git-09798f9739047e198544e672ffc7bb5b23128d52.tar.gz | |
Implement a hacky first pass at discovery.
Diffstat (limited to 'python')
| -rwxr-xr-x | python/subunit/run.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/python/subunit/run.py b/python/subunit/run.py index 01c0b0e..5c440eb 100755 --- a/python/subunit/run.py +++ b/python/subunit/run.py @@ -24,6 +24,12 @@ import sys from subunit import TestProtocolClient, get_default_formatter +try: + import discover + has_discover = True +except ImportError: + has_discover = False + class SubunitTestRunner(object): def __init__(self, stream=sys.stdout): @@ -38,10 +44,20 @@ class SubunitTestRunner(object): if __name__ == '__main__': import optparse - from unittest import TestProgram + from unittest import TestProgram, TestSuite parser = optparse.OptionParser(__doc__) - args = parser.parse_args()[1] + if has_discover: + parser.add_option("--discover", dest="discover", action="store_true", + help="Use test discovery on the given testspec.") + options, args = parser.parse_args() stream = get_default_formatter() runner = SubunitTestRunner(stream) + if has_discover and options.discover: + loader = discover.DiscoveringTestLoader() + test = TestSuite() + for arg in args: + test.addTest(loader.discover(arg)) + result = runner.run(test) + sys.exit(not result.wasSuccessful()) program = TestProgram(module=None, argv=[sys.argv[0]] + args, testRunner=runner) |
