diff options
Diffstat (limited to 'python/subunit/tests')
-rw-r--r-- | python/subunit/tests/test_filter_to_disk.py | 2 | ||||
-rw-r--r-- | python/subunit/tests/test_output_filter.py | 10 | ||||
-rw-r--r-- | python/subunit/tests/test_run.py | 2 | ||||
-rw-r--r-- | python/subunit/tests/test_subunit_filter.py | 24 | ||||
-rw-r--r-- | python/subunit/tests/test_subunit_stats.py | 2 | ||||
-rw-r--r-- | python/subunit/tests/test_subunit_tags.py | 14 | ||||
-rw-r--r-- | python/subunit/tests/test_tap2subunit.py | 2 | ||||
-rw-r--r-- | python/subunit/tests/test_test_protocol.py | 14 | ||||
-rw-r--r-- | python/subunit/tests/test_test_protocol2.py | 4 | ||||
-rw-r--r-- | python/subunit/tests/test_test_results.py | 48 |
10 files changed, 61 insertions, 61 deletions
diff --git a/python/subunit/tests/test_filter_to_disk.py b/python/subunit/tests/test_filter_to_disk.py index c0654f5..c52a4d5 100644 --- a/python/subunit/tests/test_filter_to_disk.py +++ b/python/subunit/tests/test_filter_to_disk.py @@ -33,7 +33,7 @@ class SmokeTest(TestCase): writer = StreamResultToBytes(stdin) writer.startTestRun() writer.status( - 'foo', 'success', set(['tag']), file_name='fred', + 'foo', 'success', {'tag'}, file_name='fred', file_bytes=b'abcdefg', eof=True, mime_type='text/plain') writer.stopTestRun() stdin.seek(0) diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py index e247e35..0501f79 100644 --- a/python/subunit/tests/test_output_filter.py +++ b/python/subunit/tests/test_output_filter.py @@ -197,7 +197,7 @@ class StatusStreamResultTests(TestCase): _dummy_timestamp = datetime.datetime(2013, 1, 1, 0, 0, 0, 0, UTC) def setUp(self): - super(StatusStreamResultTests, self).setUp() + super().setUp() self.patch(_o, 'create_timestamp', lambda: self._dummy_timestamp) self.test_id = self.getUniqueString() @@ -220,7 +220,7 @@ class StatusStreamResultTests(TestCase): result = get_result_for([self.option, self.test_id, '--tag', 'hello', '--tag', 'world']) self.assertThat( result._events[1], - MatchesStatusCall(test_tags=set(['hello', 'world'])) + MatchesStatusCall(test_tags={'hello', 'world'}) ) def test_all_commands_generate_timestamp(self): @@ -375,7 +375,7 @@ class StatusStreamResultTests(TestCase): result._events, MatchesListwise([ MatchesStatusCall(call='startTestRun'), - MatchesStatusCall(test_id=self.test_id, test_tags=set(['foo', 'bar'])), + MatchesStatusCall(test_id=self.test_id, test_tags={'foo', 'bar'}), MatchesStatusCall(test_id=self.test_id, test_tags=None), MatchesStatusCall(call='stopTestRun'), ]) @@ -540,7 +540,7 @@ class FileDataTests(TestCase): result._events, MatchesListwise([ MatchesStatusCall(call='startTestRun'), - MatchesStatusCall(test_tags=set(['foo'])), + MatchesStatusCall(test_tags={'foo'}), MatchesStatusCall(call='stopTestRun'), ]) ) @@ -577,7 +577,7 @@ class MatchesStatusCall(Matcher): pos = self._position_lookup[k] if call_tuple[pos] != v: return Mismatch( - "Value for key is %r, not %r" % (call_tuple[pos], v) + "Value for key is {!r}, not {!r}".format(call_tuple[pos], v) ) except IndexError: return Mismatch("Key %s is not present." % k) diff --git a/python/subunit/tests/test_run.py b/python/subunit/tests/test_run.py index 3339a82..cdf7094 100644 --- a/python/subunit/tests/test_run.py +++ b/python/subunit/tests/test_run.py @@ -70,7 +70,7 @@ class TestSubunitTestRunner(TestCase): runner = SubunitTestRunner(stream=bytestream) def list_test(test): return [], [] - class Loader(object): + class Loader: errors = ['failed import'] loader = Loader() self.patch(run, 'list_test', list_test) diff --git a/python/subunit/tests/test_subunit_filter.py b/python/subunit/tests/test_subunit_filter.py index 20e6811..a3baa5c 100644 --- a/python/subunit/tests/test_subunit_filter.py +++ b/python/subunit/tests/test_subunit_filter.py @@ -109,7 +109,7 @@ xfail todo foo = subunit.RemotedTestCase('foo') self.assertEqual( [('startTest', foo), - ('tags', set(['a']), set()), + ('tags', {'a'}, set()), ('addSuccess', foo), ('stopTest', foo), ], @@ -130,7 +130,7 @@ xfail todo def test_fixup_expected_failures(self): filtered_result = unittest.TestResult() result_filter = TestResultFilter(filtered_result, - fixup_expected_failures=set(["failed"])) + fixup_expected_failures={"failed"}) self.run_tests(result_filter) self.assertEqual(['failed', 'todo'], [failure[0].id() for failure in filtered_result.expectedFailures]) @@ -140,7 +140,7 @@ xfail todo def test_fixup_expected_errors(self): filtered_result = unittest.TestResult() result_filter = TestResultFilter(filtered_result, - fixup_expected_failures=set(["error"])) + fixup_expected_failures={"error"}) self.run_tests(result_filter) self.assertEqual(['error', 'todo'], [failure[0].id() for failure in filtered_result.expectedFailures]) @@ -150,7 +150,7 @@ xfail todo def test_fixup_unexpected_success(self): filtered_result = unittest.TestResult() result_filter = TestResultFilter(filtered_result, filter_success=False, - fixup_expected_failures=set(["passed"])) + fixup_expected_failures={"passed"}) self.run_tests(result_filter) self.assertEqual(['passed'], [passed.id() for passed in filtered_result.unexpectedSuccesses]) @@ -310,7 +310,7 @@ class TestFilterCommand(TestCase): stderr=subprocess.PIPE) out, err = ps.communicate(stream) if ps.returncode != 0: - raise RuntimeError("%s failed: %s" % (command, err)) + raise RuntimeError("{} failed: {}".format(command, err)) return out def test_default(self): @@ -321,7 +321,7 @@ class TestFilterCommand(TestCase): output = self.run_command([], byte_stream.getvalue()) events = StreamResult() ByteStreamToStreamResult(BytesIO(output)).run(events) - ids = set(event[1] for event in events._events) + ids = {event[1] for event in events._events} self.assertEqual([ ('status', 'foo', 'inprogress'), ('status', 'foo', 'skip'), @@ -331,21 +331,21 @@ class TestFilterCommand(TestCase): byte_stream = BytesIO() stream = StreamResultToBytes(byte_stream) stream.status( - test_id="foo", test_status="inprogress", test_tags=set(["a"])) + test_id="foo", test_status="inprogress", test_tags={"a"}) stream.status( - test_id="foo", test_status="success", test_tags=set(["a"])) + test_id="foo", test_status="success", test_tags={"a"}) stream.status(test_id="bar", test_status="inprogress") stream.status(test_id="bar", test_status="inprogress") stream.status( - test_id="baz", test_status="inprogress", test_tags=set(["a"])) + test_id="baz", test_status="inprogress", test_tags={"a"}) stream.status( - test_id="baz", test_status="success", test_tags=set(["a"])) + test_id="baz", test_status="success", test_tags={"a"}) output = self.run_command( ['-s', '--with-tag', 'a'], byte_stream.getvalue()) events = StreamResult() ByteStreamToStreamResult(BytesIO(output)).run(events) - ids = set(event[1] for event in events._events) - self.assertEqual(set(['foo', 'baz']), ids) + ids = {event[1] for event in events._events} + self.assertEqual({'foo', 'baz'}, ids) def test_no_passthrough(self): output = self.run_command(['--no-passthrough'], b'hi thar') diff --git a/python/subunit/tests/test_subunit_stats.py b/python/subunit/tests/test_subunit_stats.py index a4f29f2..608957d 100644 --- a/python/subunit/tests/test_subunit_stats.py +++ b/python/subunit/tests/test_subunit_stats.py @@ -64,7 +64,7 @@ xfail todo self.assertEqual(2, self.result.passed_tests) self.assertEqual(2, self.result.failed_tests) self.assertEqual(1, self.result.skipped_tests) - self.assertEqual(set(["global", "local"]), self.result.seen_tags) + self.assertEqual({"global", "local"}, self.result.seen_tags) def test_stat_formatting(self): expected = (""" diff --git a/python/subunit/tests/test_subunit_tags.py b/python/subunit/tests/test_subunit_tags.py index 936a3c7..5c8e377 100644 --- a/python/subunit/tests/test_subunit_tags.py +++ b/python/subunit/tests/test_subunit_tags.py @@ -28,7 +28,7 @@ import subunit.test_results class TestSubUnitTags(testtools.TestCase): def setUp(self): - super(TestSubUnitTags, self).setUp() + super().setUp() self.original = BytesIO() self.filtered = BytesIO() @@ -61,9 +61,9 @@ class TestSubUnitTags(testtools.TestCase): ] stream = subunit.StreamResultToBytes(self.original) stream.status( - test_id='test', test_status='inprogress', test_tags=set(['foo'])) + test_id='test', test_status='inprogress', test_tags={'foo'}) stream.status( - test_id='test', test_status='success', test_tags=set(['foo', 'bar'])) + test_id='test', test_status='success', test_tags={'foo', 'bar'}) self.original.seek(0) self.assertEqual( 0, subunit.tag_stream(self.original, self.filtered, ["quux"])) @@ -73,14 +73,14 @@ class TestSubUnitTags(testtools.TestCase): reference = BytesIO() stream = subunit.StreamResultToBytes(reference) stream.status( - test_id='test', test_status='inprogress', test_tags=set(['foo'])) + test_id='test', test_status='inprogress', test_tags={'foo'}) stream.status( - test_id='test', test_status='success', test_tags=set(['foo'])) + test_id='test', test_status='success', test_tags={'foo'}) stream = subunit.StreamResultToBytes(self.original) stream.status( - test_id='test', test_status='inprogress', test_tags=set(['foo'])) + test_id='test', test_status='inprogress', test_tags={'foo'}) stream.status( - test_id='test', test_status='success', test_tags=set(['foo', 'bar'])) + test_id='test', test_status='success', test_tags={'foo', 'bar'}) self.original.seek(0) self.assertEqual( 0, subunit.tag_stream(self.original, self.filtered, ["-bar"])) diff --git a/python/subunit/tests/test_tap2subunit.py b/python/subunit/tests/test_tap2subunit.py index 14b5086..659e523 100644 --- a/python/subunit/tests/test_tap2subunit.py +++ b/python/subunit/tests/test_tap2subunit.py @@ -39,7 +39,7 @@ class TestTAP2SubUnit(TestCase): """ def setUp(self): - super(TestTAP2SubUnit, self).setUp() + super().setUp() self.tap = StringIO() self.subunit = BytesIO() diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index d97f66d..a40591e 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -356,7 +356,7 @@ class TestTestProtocolServerLostConnection(unittest.TestCase): def do_connection_lost(self, outcome, opening): self.protocol.lineReceived(_b("test old mcdonald\n")) - self.protocol.lineReceived(_b("%s old mcdonald %s" % (outcome, opening))) + self.protocol.lineReceived(_b("{} old mcdonald {}".format(outcome, opening))) self.protocol.lostConnection() failure = subunit.RemoteError( _u("lost connection during %s report of test 'old mcdonald'") % @@ -933,13 +933,13 @@ class TestTestProtocolServerStreamTags(unittest.TestCase): def test_initial_tags(self): self.protocol.lineReceived(_b("tags: foo bar:baz quux\n")) self.assertEqual([ - ('tags', set(["foo", "bar:baz", "quux"]), set()), + ('tags', {"foo", "bar:baz", "quux"}, set()), ], self.client._events) def test_minus_removes_tags(self): self.protocol.lineReceived(_b("tags: -bar quux\n")) self.assertEqual([ - ('tags', set(["quux"]), set(["bar"])), + ('tags', {"quux"}, {"bar"}), ], self.client._events) def test_tags_do_not_get_set_on_test(self): @@ -1174,7 +1174,7 @@ class TestIsolatedTestSuite(TestCase): class TestTestProtocolClient(TestCase): def setUp(self): - super(TestTestProtocolClient, self).setUp() + super().setUp() self.io = BytesIO() self.protocol = subunit.TestProtocolClient(self.io) self.unicode_test = PlaceHolder(_u('\u2603')) @@ -1411,15 +1411,15 @@ class TestTestProtocolClient(TestCase): self.assertEqual(_b(""), self.io.getvalue()) def test_tags_add(self): - self.protocol.tags(set(['foo']), set()) + self.protocol.tags({'foo'}, set()) self.assertEqual(_b("tags: foo\n"), self.io.getvalue()) def test_tags_both(self): - self.protocol.tags(set(['quux']), set(['bar'])) + self.protocol.tags({'quux'}, {'bar'}) self.assertThat( [b"tags: quux -bar\n", b"tags: -bar quux\n"], Contains(self.io.getvalue())) def test_tags_gone(self): - self.protocol.tags(set(), set(['bar'])) + self.protocol.tags(set(), {'bar'}) self.assertEqual(_b("tags: -bar\n"), self.io.getvalue()) diff --git a/python/subunit/tests/test_test_protocol2.py b/python/subunit/tests/test_test_protocol2.py index 1f542d5..4f0eb9f 100644 --- a/python/subunit/tests/test_test_protocol2.py +++ b/python/subunit/tests/test_test_protocol2.py @@ -213,7 +213,7 @@ class TestStreamResultToBytes(TestCase): def test_tags(self): result, output = self._make_result() - result.status(test_id="bar", test_tags=set(['foo', 'bar'])) + result.status(test_id="bar", test_tags={'foo', 'bar'}) self.assertThat(CONSTANT_TAGS, Contains(output.getvalue())) def test_timestamp(self): @@ -378,7 +378,7 @@ class TestByteStreamToStreamResult(TestCase): def test_tags(self): self.check_event(CONSTANT_TAGS[0], - None, tags=set(['foo', 'bar']), test_id="bar") + None, tags={'foo', 'bar'}, test_id="bar") def test_timestamp(self): timestamp = datetime.datetime(2001, 12, 12, 12, 59, 59, 45, diff --git a/python/subunit/tests/test_test_results.py b/python/subunit/tests/test_test_results.py index c5a97e2..765454a 100644 --- a/python/subunit/tests/test_test_results.py +++ b/python/subunit/tests/test_test_results.py @@ -34,7 +34,7 @@ class LoggingDecorator(subunit.test_results.HookedTestResultDecorator): def __init__(self, decorated): self._calls = 0 - super(LoggingDecorator, self).__init__(decorated) + super().__init__(decorated) def _before_event(self): self._calls += 1 @@ -45,17 +45,17 @@ class AssertBeforeTestResult(LoggingDecorator): def __init__(self, decorated, test): self.test = test - super(AssertBeforeTestResult, self).__init__(decorated) + super().__init__(decorated) def _before_event(self): self.test.assertEqual(1, self.earlier._calls) - super(AssertBeforeTestResult, self)._before_event() + super()._before_event() class TimeCapturingResult(unittest.TestResult): def __init__(self): - super(TimeCapturingResult, self).__init__() + super().__init__() self._calls = [] self.failfast = False @@ -206,11 +206,11 @@ class TestTagCollapsingDecorator(TestCase): def test_tags_collapsed_outside_of_tests(self): result = ExtendedTestResult() tag_collapser = subunit.test_results.TagCollapsingDecorator(result) - tag_collapser.tags(set(['a']), set()) - tag_collapser.tags(set(['b']), set()) + tag_collapser.tags({'a'}, set()) + tag_collapser.tags({'b'}, set()) tag_collapser.startTest(self) self.assertEqual( - [('tags', set(['a', 'b']), set([])), + [('tags', {'a', 'b'}, set()), ('startTest', self), ], result._events @@ -220,15 +220,15 @@ class TestTagCollapsingDecorator(TestCase): result = ExtendedTestResult() tag_collapser = subunit.test_results.TagCollapsingDecorator(result) tag_collapser.startTestRun() - tag_collapser.tags(set(['a']), set()) - tag_collapser.tags(set(['b']), set()) + tag_collapser.tags({'a'}, set()) + tag_collapser.tags({'b'}, set()) tag_collapser.startTest(self) tag_collapser.addSuccess(self) tag_collapser.stopTest(self) tag_collapser.stopTestRun() self.assertEqual( [('startTestRun',), - ('tags', set(['a', 'b']), set([])), + ('tags', {'a', 'b'}, set()), ('startTest', self), ('addSuccess', self), ('stopTest', self), @@ -245,14 +245,14 @@ class TestTagCollapsingDecorator(TestCase): tag_collapser.startTest(test) tag_collapser.addSuccess(test) tag_collapser.stopTest(test) - tag_collapser.tags(set(['a']), set(['b'])) + tag_collapser.tags({'a'}, {'b'}) tag_collapser.stopTestRun() self.assertEqual( [('startTestRun',), ('startTest', test), ('addSuccess', test), ('stopTest', test), - ('tags', set(['a']), set(['b'])), + ('tags', {'a'}, {'b'}), ('stopTestRun',), ], result._events) @@ -262,13 +262,13 @@ class TestTagCollapsingDecorator(TestCase): tag_collapser = subunit.test_results.TagCollapsingDecorator(result) test = subunit.RemotedTestCase('foo') tag_collapser.startTest(test) - tag_collapser.tags(set(['a']), set()) - tag_collapser.tags(set(['b']), set(['a'])) - tag_collapser.tags(set(['c']), set()) + tag_collapser.tags({'a'}, set()) + tag_collapser.tags({'b'}, {'a'}) + tag_collapser.tags({'c'}, set()) tag_collapser.stopTest(test) self.assertEqual( [('startTest', test), - ('tags', set(['b', 'c']), set(['a'])), + ('tags', {'b', 'c'}, {'a'}), ('stopTest', test)], result._events ) @@ -278,13 +278,13 @@ class TestTagCollapsingDecorator(TestCase): tag_collapser = subunit.test_results.TagCollapsingDecorator(result) test = subunit.RemotedTestCase('foo') tag_collapser.startTest(test) - tag_collapser.tags(set(), set(['a'])) - tag_collapser.tags(set(['a', 'b']), set()) - tag_collapser.tags(set(['c']), set()) + tag_collapser.tags(set(), {'a'}) + tag_collapser.tags({'a', 'b'}, set()) + tag_collapser.tags({'c'}, set()) tag_collapser.stopTest(test) self.assertEqual( [('startTest', test), - ('tags', set(['a', 'b', 'c']), set()), + ('tags', {'a', 'b', 'c'}, set()), ('stopTest', test)], result._events ) @@ -298,12 +298,12 @@ class TestTagCollapsingDecorator(TestCase): tag_collapser = subunit.test_results.TagCollapsingDecorator(result) test = subunit.RemotedTestCase('foo') tag_collapser.startTest(test) - tag_collapser.tags(set(['a']), set()) + tag_collapser.tags({'a'}, set()) tag_collapser.addSuccess(test) tag_collapser.stopTest(test) self.assertEqual( [('startTest', test), - ('tags', set(['a']), set()), + ('tags', {'a'}, set()), ('addSuccess', test), ('stopTest', test)], result._events @@ -381,7 +381,7 @@ class TestTimeCollapsingDecorator(TestCase): class TestByTestResultTests(testtools.TestCase): def setUp(self): - super(TestByTestResultTests, self).setUp() + super().setUp() self.log = [] self.result = subunit.test_results.TestByTestResult(self.on_test) self.result._now = iter(range(5)).__next__ @@ -425,7 +425,7 @@ class TestByTestResultTests(testtools.TestCase): self.result.startTest(self) self.result.addSuccess(self) self.result.stopTest(self) - self.assertCalled(status='success', tags=set(['foo'])) + self.assertCalled(status='success', tags={'foo'}) def test_add_error(self): self.result.startTest(self) |