diff options
| author | Robert Collins <robertc@robertcollins.net> | 2009-07-20 18:13:55 +1000 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2009-07-20 18:13:55 +1000 |
| commit | 0dc614b47e7ec1b191cfd27ea65d2526b8fde45e (patch) | |
| tree | 03320f2e2597572be6d2392a2826a1e018255e82 /python/subunit/tests/test_test_protocol.py | |
| parent | 57f483adeb597e93b9af7afba6ee10bf7af72c2e (diff) | |
| download | subunit-git-0dc614b47e7ec1b191cfd27ea65d2526b8fde45e.tar.gz | |
Teach python to call TestResult.time on time: tags.
Diffstat (limited to 'python/subunit/tests/test_test_protocol.py')
| -rw-r--r-- | python/subunit/tests/test_test_protocol.py | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index ead0ac6..1ffaf30 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -24,39 +24,40 @@ import subunit import sys import time -try: - class MockTestProtocolServerClient(object): - """A mock protocol server client to test callbacks.""" - def __init__(self): - self.end_calls = [] - self.error_calls = [] - self.failure_calls = [] - self.skip_calls = [] - self.start_calls = [] - self.success_calls = [] - super(MockTestProtocolServerClient, self).__init__() +class MockTestProtocolServerClient(object): + """A mock protocol server client to test callbacks.""" - def addError(self, test, error): - self.error_calls.append((test, error)) + def __init__(self): + self.end_calls = [] + self.error_calls = [] + self.failure_calls = [] + self.skip_calls = [] + self.start_calls = [] + self.success_calls = [] + self._time = None + super(MockTestProtocolServerClient, self).__init__() - def addFailure(self, test, error): - self.failure_calls.append((test, error)) + def addError(self, test, error): + self.error_calls.append((test, error)) - def addSkip(self, test, reason): - self.skip_calls.append((test, reason)) + def addFailure(self, test, error): + self.failure_calls.append((test, error)) - def addSuccess(self, test): - self.success_calls.append(test) + def addSkip(self, test, reason): + self.skip_calls.append((test, reason)) - def stopTest(self, test): - self.end_calls.append(test) + def addSuccess(self, test): + self.success_calls.append(test) - def startTest(self, test): - self.start_calls.append(test) + def stopTest(self, test): + self.end_calls.append(test) -except AttributeError: - MockTestProtocolServer = None + def startTest(self, test): + self.start_calls.append(test) + + def time(self, time): + self._time = time class TestMockTestProtocolServer(unittest.TestCase): @@ -763,15 +764,22 @@ class TestTestProtocolServerStreamTags(unittest.TestCase): class TestTestProtocolServerStreamTime(unittest.TestCase): """Test managing time information at the protocol level.""" - def setUp(self): - self.client = MockTestProtocolServerClient() + def test_time_accepted_stdlib(self): + self.result = unittest.TestResult() self.stream = StringIO() - self.protocol = subunit.TestProtocolServer(self.client, + self.protocol = subunit.TestProtocolServer(self.result, stream=self.stream) + self.protocol.lineReceived("time: 2001-12-12 12:59:59Z\n") + self.assertEqual("", self.stream.getvalue()) - def test_time_accepted(self): + def test_time_accepted_extended(self): + self.result = MockTestProtocolServerClient() + self.stream = StringIO() + self.protocol = subunit.TestProtocolServer(self.result, + stream=self.stream) self.protocol.lineReceived("time: 2001-12-12 12:59:59Z\n") self.assertEqual("", self.stream.getvalue()) + self.assertEqual(1008161999, self.result._time) class TestRemotedTestCase(unittest.TestCase): |
