diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-05 19:33:18 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-05 19:33:18 -0500 |
commit | 208a2004a55c232134f5b70d81fe8e638beddb85 (patch) | |
tree | c1087900e4c59ce944393f2d282ca0c7cd65792a /tests/test_transcript.py | |
parent | 069ecc888e7fb826296a976b21615afe7bb95b89 (diff) | |
download | cmd2-git-208a2004a55c232134f5b70d81fe8e638beddb85.tar.gz |
Fixed flaw in unit tests so they can be reliably parallelized.
Fixed a bug which made parallelizing the unit tests with pytest-xdist unreliable.
The unit tests can now be run in parallel using pytest-xdist for a dramatic speedup on multicore machines. To do this use:
py.test -n4
(where 4 is the number of cores you wish to parallelize across)
Diffstat (limited to 'tests/test_transcript.py')
-rw-r--r-- | tests/test_transcript.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/tests/test_transcript.py b/tests/test_transcript.py index 1aab653c..9f6d8943 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -24,13 +24,13 @@ class CmdLineApp(Cmd): maxrepeats = 3 redirector = '->' - opts = [ - make_option('-p', '--piglatin', action="store_true", help="atinLay"), - make_option('-s', '--shout', action="store_true", - help="N00B EMULATION MODE"), - make_option('-r', '--repeat', type="int", help="output [n] times") - ] + def __init__(self, *args, **kwargs): + super(CmdLineApp, self).__init__(*args, **kwargs) + self.settable.append('maxrepeats Max number of `--repeat`s allowed') + opts = [make_option('-p', '--piglatin', action="store_true", help="atinLay"), + make_option('-s', '--shout', action="store_true", help="N00B EMULATION MODE"), + make_option('-r', '--repeat', type="int", help="output [n] times")] @options(opts, arg_desc='(text to say)') def do_speak(self, arg, opts=None): """Repeats what you tell me to.""" @@ -72,8 +72,6 @@ class DemoApp(Cmd): def _cmdline_app(): c = CmdLineApp() c.stdout = StdOut() - # c.shortcuts.update({'&': 'speak', 'h': 'hello'}) - c.settable.append('maxrepeats Max number of `--repeat`s allowed') return c @@ -261,7 +259,6 @@ def test_select_options(_demo_app): def test_transcript_from_cmdloop(request, capsys): # Create a cmd2.Cmd() instance and make sure basic settings are like we want for test app = CmdLineApp() - app.settable.append('maxrepeats Max number of `--repeat`s allowed') # Get location of the transcript test_dir = os.path.dirname(request.module.__file__) |