diff options
| author | Robert Collins <robertc@robertcollins.net> | 2013-02-22 18:09:06 +1300 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2013-02-22 18:09:06 +1300 |
| commit | b2def216dbc1124a19ef63b1cfa6fce32c54e660 (patch) | |
| tree | d04d5bbe6c64ca498f71bd0d636feda1de94d9a3 /python/subunit/tests | |
| parent | 2a943c86b1eec4c71dcdb567789e81dee15e6df9 (diff) | |
| download | subunit-git-b2def216dbc1124a19ef63b1cfa6fce32c54e660.tar.gz | |
Start on an encoder.
Diffstat (limited to 'python/subunit/tests')
| -rw-r--r-- | python/subunit/tests/__init__.py | 2 | ||||
| -rw-r--r-- | python/subunit/tests/test_test_protocol2.py | 47 |
2 files changed, 49 insertions, 0 deletions
diff --git a/python/subunit/tests/__init__.py b/python/subunit/tests/__init__.py index e0e1eb1..4275229 100644 --- a/python/subunit/tests/__init__.py +++ b/python/subunit/tests/__init__.py @@ -25,6 +25,7 @@ from subunit.tests import ( test_subunit_tags, test_tap2subunit, test_test_protocol, + test_test_protocol2, test_test_results, ) @@ -35,6 +36,7 @@ def test_suite(): result.addTest(test_progress_model.test_suite()) result.addTest(test_test_results.test_suite()) result.addTest(test_test_protocol.test_suite()) + result.addTest(test_test_protocol2.test_suite()) result.addTest(test_tap2subunit.test_suite()) result.addTest(test_subunit_filter.test_suite()) result.addTest(test_subunit_tags.test_suite()) diff --git a/python/subunit/tests/test_test_protocol2.py b/python/subunit/tests/test_test_protocol2.py new file mode 100644 index 0000000..9409ba2 --- /dev/null +++ b/python/subunit/tests/test_test_protocol2.py @@ -0,0 +1,47 @@ +# +# subunit: extensions to Python unittest to get test results from subprocesses. +# Copyright (C) 2013 Robert Collins <robertc@robertcollins.net> +# +# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause +# license at the users choice. A copy of both licenses are available in the +# project source as Apache-2.0 and BSD. You may not use this file except in +# compliance with one of these two licences. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# license you chose for the specific language governing permissions and +# limitations under that license. +# + +from io import BytesIO + +from testtools import TestCase +from testtools.tests.test_testresult import TestStreamResultContract + +import subunit + +class TestStreamResultToBytesContract(TestCase, TestStreamResultContract): + """Check that StreamResult behaves as testtools expects.""" + + def _make_result(self): + return subunit.StreamResultToBytes(BytesIO()) + + +class TestStreamResultToBytes(TestCase): + + def _make_result(self): + output = BytesIO() + return subunit.StreamResultToBytes(output), output + + def test_trivial_enumeration(self): + result, output = self._make_result() + result.status("foo", 'exists') + self.assertEqual(b'\xb3\x29\x01\0\0\x0f\0\x03foo\x99\x0c\x34\x3f', + output.getvalue()) + + +def test_suite(): + loader = subunit.tests.TestUtil.TestLoader() + result = loader.loadTestsFromName(__name__) + return result |
