diff options
| author | Robert Collins <robertc@robertcollins.net> | 2009-09-08 22:08:23 +1000 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2009-09-08 22:08:23 +1000 |
| commit | 3b11398f6c6247545d846c2bb607b6ff526ecbc1 (patch) | |
| tree | 45511636f6568dd6ea0f0279d282665cd456f0cb /python/subunit/tests | |
| parent | 56f366ba26b9bd81079f2ce77c851b0324ef28f6 (diff) | |
| parent | 95a5816c1bb8808141416005c5a203bc4d7f8599 (diff) | |
| download | subunit-git-3b11398f6c6247545d846c2bb607b6ff526ecbc1.tar.gz | |
Merge python API changes for tagging.
Diffstat (limited to 'python/subunit/tests')
| -rw-r--r-- | python/subunit/tests/test_subunit_stats.py | 6 | ||||
| -rw-r--r-- | python/subunit/tests/test_subunit_tags.py | 1 | ||||
| -rw-r--r-- | python/subunit/tests/test_test_protocol.py | 55 |
3 files changed, 32 insertions, 30 deletions
diff --git a/python/subunit/tests/test_subunit_stats.py b/python/subunit/tests/test_subunit_stats.py index e2f30fc..a8540bb 100644 --- a/python/subunit/tests/test_subunit_stats.py +++ b/python/subunit/tests/test_subunit_stats.py @@ -39,7 +39,7 @@ class TestTestResultStats(unittest.TestCase): self.assertEqual(0, self.result.total_tests) self.assertEqual(0, self.result.passed_tests) self.assertEqual(0, self.result.failed_tests) - self.assertEqual(set(), self.result.tags) + self.assertEqual(set(), self.result.seen_tags) def setUpUsedStream(self): self.input_stream.write("""tags: global @@ -65,7 +65,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.tags) + self.assertEqual(set(["global", "local"]), self.result.seen_tags) def test_stat_formatting(self): expected = (""" @@ -73,7 +73,7 @@ Total tests: 5 Passed tests: 2 Failed tests: 2 Skipped tests: 1 -Tags: global, local +Seen tags: global, local """)[1:] self.setUpUsedStream() self.result.formatStats() diff --git a/python/subunit/tests/test_subunit_tags.py b/python/subunit/tests/test_subunit_tags.py index 66cff68..c23e810 100644 --- a/python/subunit/tests/test_subunit_tags.py +++ b/python/subunit/tests/test_subunit_tags.py @@ -23,6 +23,7 @@ import unittest from StringIO import StringIO import subunit +import subunit.test_results class TestSubUnitTags(unittest.TestCase): diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index 2b90b9e..9a39c6b 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -71,6 +71,19 @@ class MockTestProtocolServerClient(object): self._time = time +class MockExtendedTestProtocolServerClient(MockTestProtocolServerClient): + """An extended TestResult for testing which implements tags() etc.""" + + def __init__(self): + MockTestProtocolServerClient.__init__(self) + self.new_tags = set() + self.gone_tags = set() + + def tags(self, new_tags, gone_tags): + self.new_tags = new_tags + self.gone_tags = gone_tags + + class TestMockTestProtocolServer(unittest.TestCase): def test_start_test(self): @@ -806,53 +819,41 @@ class TestTestProtocolServerStreamTags(unittest.TestCase): """Test managing tags on the protocol level.""" def setUp(self): - self.client = MockTestProtocolServerClient() + self.client = MockExtendedTestProtocolServerClient() self.protocol = subunit.TestProtocolServer(self.client) def test_initial_tags(self): self.protocol.lineReceived("tags: foo bar:baz quux\n") self.assertEqual(set(["foo", "bar:baz", "quux"]), - self.protocol.tags) + self.client.new_tags) + self.assertEqual(set(), self.client.gone_tags) def test_minus_removes_tags(self): self.protocol.lineReceived("tags: foo bar\n") + self.assertEqual(set(["foo", "bar"]), + self.client.new_tags) + self.assertEqual(set(), self.client.gone_tags) self.protocol.lineReceived("tags: -bar quux\n") - self.assertEqual(set(["foo", "quux"]), - self.protocol.tags) + self.assertEqual(set(["quux"]), self.client.new_tags) + self.assertEqual(set(["bar"]), self.client.gone_tags) - def test_tags_get_set_on_test_no_tags(self): + def test_tags_do_not_get_set_on_test(self): self.protocol.lineReceived("test mcdonalds farm\n") test = self.client.start_calls[-1] - self.assertEqual(set(), test.tags) + self.assertEqual(None, getattr(test, 'tags', None)) - def test_tags_get_set_on_test_protocol_tags_only(self): + def test_tags_do_not_get_set_on_global_tags(self): self.protocol.lineReceived("tags: foo bar\n") self.protocol.lineReceived("test mcdonalds farm\n") test = self.client.start_calls[-1] - self.assertEqual(set(["foo", "bar"]), test.tags) - - def test_tags_get_set_on_test_simple(self): - self.protocol.lineReceived("test mcdonalds farm\n") - test = self.client.start_calls[-1] - self.protocol.lineReceived("tags: foo bar\n") - self.assertEqual(set(["foo", "bar"]), test.tags) - self.assertEqual(set(), self.protocol.tags) + self.assertEqual(None, getattr(test, 'tags', None)) - def test_tags_get_set_on_test_minus_removes(self): + def test_tags_get_set_on_test_tags(self): self.protocol.lineReceived("test mcdonalds farm\n") test = self.client.start_calls[-1] self.protocol.lineReceived("tags: foo bar\n") - self.protocol.lineReceived("tags: -bar quux\n") - self.assertEqual(set(["foo", "quux"]), test.tags) - self.assertEqual(set(), self.protocol.tags) - - def test_test_tags_inherit_protocol_tags(self): - self.protocol.lineReceived("tags: foo bar\n") - self.protocol.lineReceived("test mcdonalds farm\n") - test = self.client.start_calls[-1] - self.protocol.lineReceived("tags: -bar quux\n") - self.assertEqual(set(["foo", "quux"]), test.tags) - self.assertEqual(set(["foo", "bar"]), self.protocol.tags) + self.protocol.lineReceived("success mcdonalds farm\n") + self.assertEqual(None, getattr(test, 'tags', None)) class TestTestProtocolServerStreamTime(unittest.TestCase): |
