diff options
author | Robert Collins <robertc@robertcollins.net> | 2012-12-19 16:37:47 +1300 |
---|---|---|
committer | Robert Collins <robertc@robertcollins.net> | 2012-12-19 16:37:47 +1300 |
commit | 41939b95d254e75ef4e7a5525e4742c7e599499e (patch) | |
tree | 3f1a06e51e1bf7d86ab9f6a84a6c96efe1383cad /testrepository/tests/test_testcommand.py | |
parent | b4fdb43317ad5611ea3816e94a5c9b1cc838f762 (diff) | |
download | testrepository-41939b95d254e75ef4e7a5525e4742c7e599499e.tar.gz |
* It's now possible to configure ``test_run_concurrency`` in ``.testr.conf``
to have concurrency defined by a callout. (Robert Collins)
Diffstat (limited to 'testrepository/tests/test_testcommand.py')
-rw-r--r-- | testrepository/tests/test_testcommand.py | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/testrepository/tests/test_testcommand.py b/testrepository/tests/test_testcommand.py index 2b66997..ecdc012 100644 --- a/testrepository/tests/test_testcommand.py +++ b/testrepository/tests/test_testcommand.py @@ -18,7 +18,7 @@ import os.path import optparse import re -from testtools.matchers import MatchesException, Raises +from testtools.matchers import MatchesException, raises from testtools.testresult.doubles import ExtendedTestResult from testrepository.commands import run @@ -78,14 +78,14 @@ class TestTestCommand(ResourcedTestCase): def test_get_run_command_no_config_file_errors(self): ui, command = self.get_test_ui_and_cmd() self.assertThat(command.get_run_command, - Raises(MatchesException(ValueError('No .testr.conf config file')))) + raises(ValueError('No .testr.conf config file'))) def test_get_run_command_no_config_settings_errors(self): ui, command = self.get_test_ui_and_cmd() self.set_config('') self.assertThat(command.get_run_command, - Raises(MatchesException(ValueError( - 'No test_command option present in .testr.conf')))) + raises(ValueError( + 'No test_command option present in .testr.conf'))) def test_get_run_command_returns_fixture_makes_IDFILE(self): ui, command = self.get_test_ui_and_cmd() @@ -244,6 +244,40 @@ class TestTestCommand(ResourcedTestCase): self.set_config('[DEFAULT]\nfilter_tags=foo bar\n') self.assertEqual(set(['foo', 'bar']), command.get_filter_tags()) + def test_callout_concurrency(self): + ui, command = self.get_test_ui_and_cmd() + ui.proc_outputs = ['4'] + self.set_config( + '[DEFAULT]\ntest_run_concurrency=probe\n' + 'test_command=foo\n') + fixture = self.useFixture(command.get_run_command()) + self.assertEqual(4, fixture.callout_concurrency()) + self.assertEqual([ + ('popen', ('probe',), {'shell': True, 'stdin': -1, 'stdout': -1}), + ('communicate',)], ui.outputs) + + def test_callout_concurrency_failed(self): + ui, command = self.get_test_ui_and_cmd() + ui.proc_results = [1] + self.set_config( + '[DEFAULT]\ntest_run_concurrency=probe\n' + 'test_command=foo\n') + fixture = self.useFixture(command.get_run_command()) + self.assertThat(lambda:fixture.callout_concurrency(), raises( + ValueError("test_run_concurrency failed: exit code 1, stderr=''"))) + self.assertEqual([ + ('popen', ('probe',), {'shell': True, 'stdin': -1, 'stdout': -1}), + ('communicate',)], ui.outputs) + + def test_callout_concurrency_not_set(self): + ui, command = self.get_test_ui_and_cmd() + self.set_config( + '[DEFAULT]\n' + 'test_command=foo\n') + fixture = self.useFixture(command.get_run_command()) + self.assertEqual(None, fixture.callout_concurrency()) + self.assertEqual([], ui.outputs) + def test_make_result(self): # Just a simple 'the dots are joined' test. More later. ui, command = self.get_test_ui_and_cmd() |