summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJonathan Lange <jml@canonical.com>2011-02-11 16:45:49 +0000
committerJonathan Lange <jml@canonical.com>2011-02-11 16:45:49 +0000
commit6d6297fef98e8e86cdea243922cc2e79d5c4641f (patch)
tree4935df60d4fd6071fb8db13f349cc4a79e1e471f /python
parenta079bfb4c2a37a7d12b0f2cff51f079bf81c889f (diff)
downloadsubunit-git-6d6297fef98e8e86cdea243922cc2e79d5c4641f.tar.gz
Failing test that demonstrates the bug.
Diffstat (limited to 'python')
-rw-r--r--python/subunit/tests/test_subunit_filter.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/python/subunit/tests/test_subunit_filter.py b/python/subunit/tests/test_subunit_filter.py
index 89f5212..786ef46 100644
--- a/python/subunit/tests/test_subunit_filter.py
+++ b/python/subunit/tests/test_subunit_filter.py
@@ -16,9 +16,14 @@
"""Tests for subunit.TestResultFilter."""
+from datetime import datetime
+from subunit import iso8601
import unittest
from StringIO import StringIO
+from testtools import TestCase
+from testtools.testresult.doubles import ExtendedTestResult
+
import subunit
from subunit.test_results import TestResultFilter
@@ -31,7 +36,7 @@ def make_stream(bytes):
return stream
-class TestTestResultFilter(unittest.TestCase):
+class TestTestResultFilter(TestCase):
"""Test for TestResultFilter, a TestResult object which filters tests."""
# While TestResultFilter works on python objects, using a subunit stream
@@ -135,6 +140,29 @@ xfail todo
# Only success should pass
self.assertEqual(1, filtered_result.testsRun)
+ def test_time_ordering_preserved(self):
+ # Passing a subunit stream through TestResultFilter preserves the
+ # relative ordering of 'time' directives and any other subunit
+ # directives that are still included.
+ dates = [
+ datetime(year=2000, month=1, day=i, tzinfo=iso8601.Utc())
+ for i in range(1, 4)]
+ subunit_stream = '\n'.join([
+ "time: %s",
+ "test: foo",
+ "time: %s",
+ "error: foo",
+ "time: %s"]) % tuple(dates)
+ result = ExtendedTestResult()
+ result_filter = TestResultFilter(result)
+ self.run_tests(result_filter, subunit_stream)
+ self.assertEquals(
+ [('time', dates[0]),
+ ('startTest', 'foo'),
+ ('time', dates[1]),
+ ('addError', 'foo'),
+ ('time', dates[2])], result._events)
+
def test_suite():
loader = subunit.tests.TestUtil.TestLoader()