From 1bb81bd80c26f41555f676d9f6b164be9c061e61 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Mon, 5 Oct 2009 05:53:44 +1100 Subject: Create TracebackContent for adapting exc_info tuples. --- python/subunit/tests/test_content.py | 18 +++++++++++++++++- python/subunit/tests/test_content_type.py | 7 +++++++ 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'python/subunit/tests') 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)) -- cgit v1.2.1