diff options
| author | Robert Collins <robertc@robertcollins.net> | 2009-10-05 05:53:44 +1100 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2009-10-05 05:53:44 +1100 |
| commit | 1bb81bd80c26f41555f676d9f6b164be9c061e61 (patch) | |
| tree | 150e8a9d01cbf78f8cd880ce1bbbe1078ed8f9c5 /python/subunit/tests | |
| parent | 869d2a4f792a4d5d2c9f7f55d95ba216f0fbe4f1 (diff) | |
| download | subunit-git-1bb81bd80c26f41555f676d9f6b164be9c061e61.tar.gz | |
Create TracebackContent for adapting exc_info tuples.
Diffstat (limited to 'python/subunit/tests')
| -rw-r--r-- | python/subunit/tests/test_content.py | 18 | ||||
| -rw-r--r-- | python/subunit/tests/test_content_type.py | 7 |
2 files changed, 24 insertions, 1 deletions
diff --git a/python/subunit/tests/test_content.py b/python/subunit/tests/test_content.py index 869717e..8075cf9 100644 --- a/python/subunit/tests/test_content.py +++ b/python/subunit/tests/test_content.py @@ -16,7 +16,7 @@ import unittest import subunit -from subunit.content import Content +from subunit.content import Content, TracebackContent from subunit.content_type import ContentType @@ -39,3 +39,19 @@ class TestContent(unittest.TestCase): content = Content(content_type, lambda:["bytes"]) self.assertEqual(content_type, content.content_type) self.assertEqual(["bytes"], list(content.iter_bytes())) + + +class TestTracebackContent(unittest.TestCase): + + def test___init___None_errors(self): + self.assertRaises(ValueError, TracebackContent, None) + + def test___init___sets_ivars(self): + content = TracebackContent(subunit.RemoteError("weird")) + content_type = ContentType("text", "x-traceback", + {"language":"python"}) + self.assertEqual(content_type, content.content_type) + result = unittest.TestResult() + expected = result._exc_info_to_string(subunit.RemoteError("weird"), + subunit.RemotedTestCase('')) + self.assertEqual(expected, ''.join(list(content.iter_bytes()))) diff --git a/python/subunit/tests/test_content_type.py b/python/subunit/tests/test_content_type.py index 7e24316..3a3fa2c 100644 --- a/python/subunit/tests/test_content_type.py +++ b/python/subunit/tests/test_content_type.py @@ -41,3 +41,10 @@ class TestContentType(unittest.TestCase): def test___init___with_parameters(self): content_type = ContentType("foo", "bar", {"quux":"thing"}) self.assertEqual({"quux":"thing"}, content_type.parameters) + + def test___eq__(self): + content_type1 = ContentType("foo", "bar", {"quux":"thing"}) + content_type2 = ContentType("foo", "bar", {"quux":"thing"}) + content_type3 = ContentType("foo", "bar", {"quux":"thing2"}) + self.assertTrue(content_type1.__eq__(content_type2)) + self.assertFalse(content_type1.__eq__(content_type3)) |
