From 5c3c88265d467555e2e92f1a7f445f69b3c0a261 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sun, 7 Dec 2008 10:01:15 +1100 Subject: Implement skip support for the protocol server (but not for python clients as python has no standard way to describe skips. --- python/subunit/tests/test_test_protocol.py | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'python/subunit/tests/test_test_protocol.py') diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index 0083954..d12b0ac 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -396,6 +396,18 @@ class TestTestProtocolServerLostConnection(unittest.TestCase): self.assertEqual(self.client.failure_calls, []) self.assertEqual(self.client.success_calls, [self.test]) + def test_lost_connection_during_skip(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("skip old mcdonald [\n") + self.protocol.lostConnection() + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, [ + (self.test, subunit.RemoteError("lost connection during skip " + "report of test 'old mcdonald'"))]) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, []) + class TestTestProtocolServerAddError(unittest.TestCase): @@ -493,6 +505,61 @@ class TestTestProtocolServerAddFailure(unittest.TestCase): self.failure_quoted_bracket("failure:") +class TestTestProtocolServerAddSkip(unittest.TestCase): + """Tests for the skip keyword. + + In python this thunks through to Success due to stdlib limitations. + """ + + def setUp(self): + """Setup a test object ready to be skipped.""" + self.client = MockTestProtocolServerClient() + self.protocol = subunit.TestProtocolServer(self.client) + self.protocol.lineReceived("test mcdonalds farm\n") + self.test = self.client.start_calls[-1] + + def simple_skip_keyword(self, keyword): + self.protocol.lineReceived("%s mcdonalds farm\n" % keyword) + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, [self.test]) + + def test_simple_skip(self): + self.simple_skip_keyword("skip") + + def test_simple_skip_colon(self): + self.simple_skip_keyword("skip:") + + def test_skip_empty_message(self): + self.protocol.lineReceived("skip mcdonalds farm [\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, [self.test]) + + def skip_quoted_bracket(self, keyword): + # This tests it is accepted, but cannot test it is used today, because + # of not having a way to expose it in python so far. + self.protocol.lineReceived("%s mcdonalds farm [\n" % keyword) + self.protocol.lineReceived(" ]\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, [self.test]) + + def test_skip_quoted_bracket(self): + self.skip_quoted_bracket("skip") + + def test_skip_colon_quoted_bracket(self): + self.skip_quoted_bracket("skip:") + + class TestTestProtocolServerAddSuccess(unittest.TestCase): def setUp(self): -- cgit v1.2.1 From 9a915af1f70344c63f232a2d82d14cf6e01aa84f Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sun, 7 Dec 2008 14:37:48 +1100 Subject: Add XFAIL support. As with Skip, there is no python object representation of the skip, because there is no standard for reporting them. --- python/subunit/tests/test_test_protocol.py | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'python/subunit/tests/test_test_protocol.py') diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index d12b0ac..842e887 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -505,6 +505,61 @@ class TestTestProtocolServerAddFailure(unittest.TestCase): self.failure_quoted_bracket("failure:") +class TestTestProtocolServerAddxFail(unittest.TestCase): + """Tests for the xfail keyword. + + In python this thunks through to Success due to stdlib limitations. + """ + + def setUp(self): + """Setup a test object ready to be xfailed.""" + self.client = MockTestProtocolServerClient() + self.protocol = subunit.TestProtocolServer(self.client) + self.protocol.lineReceived("test mcdonalds farm\n") + self.test = self.client.start_calls[-1] + + def simple_xfail_keyword(self, keyword): + self.protocol.lineReceived("%s mcdonalds farm\n" % keyword) + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, [self.test]) + + def test_simple_xfail(self): + self.simple_xfail_keyword("xfail") + + def test_simple_xfail_colon(self): + self.simple_xfail_keyword("xfail:") + + def test_xfail_empty_message(self): + self.protocol.lineReceived("xfail mcdonalds farm [\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, [self.test]) + + def xfail_quoted_bracket(self, keyword): + # This tests it is accepted, but cannot test it is used today, because + # of not having a way to expose it in python so far. + self.protocol.lineReceived("%s mcdonalds farm [\n" % keyword) + self.protocol.lineReceived(" ]\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, [self.test]) + + def test_xfail_quoted_bracket(self): + self.xfail_quoted_bracket("xfail") + + def test_xfail_colon_quoted_bracket(self): + self.xfail_quoted_bracket("xfail:") + + class TestTestProtocolServerAddSkip(unittest.TestCase): """Tests for the skip keyword. -- cgit v1.2.1 From 755f5d6f16afeb65b55dcd6852974307eb690639 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sun, 7 Dec 2008 14:54:50 +1100 Subject: Handle comments for test success (in wire parser) and connection loss for XFAIL and success. --- python/subunit/tests/test_test_protocol.py | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'python/subunit/tests/test_test_protocol.py') diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index 842e887..9c17106 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -408,6 +408,30 @@ class TestTestProtocolServerLostConnection(unittest.TestCase): self.assertEqual(self.client.failure_calls, []) self.assertEqual(self.client.success_calls, []) + def test_lost_connection_during_xfail(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("xfail old mcdonald [\n") + self.protocol.lostConnection() + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, [ + (self.test, subunit.RemoteError("lost connection during xfail " + "report of test 'old mcdonald'"))]) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, []) + + def test_lost_connection_during_success(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("success old mcdonald [\n") + self.protocol.lostConnection() + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, [ + (self.test, subunit.RemoteError("lost connection during success " + "report of test 'old mcdonald'"))]) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, []) + class TestTestProtocolServerAddError(unittest.TestCase): @@ -642,6 +666,33 @@ class TestTestProtocolServerAddSuccess(unittest.TestCase): def test_simple_success_colon(self): self.simple_success_keyword("successful:") + def test_success_empty_message(self): + self.protocol.lineReceived("success mcdonalds farm [\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, [self.test]) + + def success_quoted_bracket(self, keyword): + # This tests it is accepted, but cannot test it is used today, because + # of not having a way to expose it in python so far. + self.protocol.lineReceived("%s mcdonalds farm [\n" % keyword) + self.protocol.lineReceived(" ]\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, [self.test]) + + def test_success_quoted_bracket(self): + self.success_quoted_bracket("success") + + def test_success_colon_quoted_bracket(self): + self.success_quoted_bracket("success:") + class TestRemotedTestCase(unittest.TestCase): -- cgit v1.2.1 From 2c1f561d6466270f2d0f5d9064c3f3a16ea3110c Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Mon, 8 Dec 2008 12:59:41 +1100 Subject: Swallow time: commands when seen. --- python/subunit/tests/test_test_protocol.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'python/subunit/tests/test_test_protocol.py') diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index 9088819..a041aa0 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -22,6 +22,7 @@ from StringIO import StringIO import os import subunit import sys +import time try: class MockTestProtocolServerClient(object): @@ -747,6 +748,20 @@ class TestTestProtocolServerStreamTags(unittest.TestCase): self.assertEqual(set(["foo", "bar"]), self.protocol.tags) +class TestTestProtocolServerStreamTime(unittest.TestCase): + """Test managing time information at the protocol level.""" + + def setUp(self): + self.client = MockTestProtocolServerClient() + self.stream = StringIO() + self.protocol = subunit.TestProtocolServer(self.client, + stream=self.stream) + + def test_time_accepted(self): + self.protocol.lineReceived("time: 2001-12-12 12:59:59Z\n") + self.assertEqual("", self.stream.getvalue()) + + class TestRemotedTestCase(unittest.TestCase): def test_simple(self): -- cgit v1.2.1 From a212722f3f93a8d8bc3620d0ac5276e1491cee29 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Mon, 15 Dec 2008 05:37:08 +1100 Subject: Review feedback on the skip/xfail/success comment branch. --- python/subunit/tests/test_test_protocol.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'python/subunit/tests/test_test_protocol.py') diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index a84e03e..1f9e3a9 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -1,5 +1,5 @@ # -# subunit: extensions to python unittest to get test results from subprocesses. +# subunit: extensions to Python unittest to get test results from subprocesses. # Copyright (C) 2005 Robert Collins # # This program is free software; you can redistribute it and/or modify @@ -533,7 +533,8 @@ class TestTestProtocolServerAddFailure(unittest.TestCase): class TestTestProtocolServerAddxFail(unittest.TestCase): """Tests for the xfail keyword. - In python this thunks through to Success due to stdlib limitations. + In Python this thunks through to Success due to stdlib limitations (see + README). """ def setUp(self): @@ -568,7 +569,7 @@ class TestTestProtocolServerAddxFail(unittest.TestCase): def xfail_quoted_bracket(self, keyword): # This tests it is accepted, but cannot test it is used today, because - # of not having a way to expose it in python so far. + # of not having a way to expose it in Python so far. self.protocol.lineReceived("%s mcdonalds farm [\n" % keyword) self.protocol.lineReceived(" ]\n") self.protocol.lineReceived("]\n") @@ -588,7 +589,8 @@ class TestTestProtocolServerAddxFail(unittest.TestCase): class TestTestProtocolServerAddSkip(unittest.TestCase): """Tests for the skip keyword. - In python this thunks through to Success due to stdlib limitations. + In Python this thunks through to Success due to stdlib limitations. (See + README). """ def setUp(self): @@ -623,7 +625,7 @@ class TestTestProtocolServerAddSkip(unittest.TestCase): def skip_quoted_bracket(self, keyword): # This tests it is accepted, but cannot test it is used today, because - # of not having a way to expose it in python so far. + # of not having a way to expose it in Python so far. self.protocol.lineReceived("%s mcdonalds farm [\n" % keyword) self.protocol.lineReceived(" ]\n") self.protocol.lineReceived("]\n") @@ -678,7 +680,7 @@ class TestTestProtocolServerAddSuccess(unittest.TestCase): def success_quoted_bracket(self, keyword): # This tests it is accepted, but cannot test it is used today, because - # of not having a way to expose it in python so far. + # of not having a way to expose it in Python so far. self.protocol.lineReceived("%s mcdonalds farm [\n" % keyword) self.protocol.lineReceived(" ]\n") self.protocol.lineReceived("]\n") -- cgit v1.2.1