summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2021-07-27 11:45:23 +0100
committerColin Watson <cjwatson@debian.org>2021-07-27 11:45:23 +0100
commitfd21ba4cfc531e0906aad7b79a6b412fa778199e (patch)
tree0c800066924bc8ec785a071d47f37adaa47c3416
parent097f65bfee8715de1ad5258cb9bc425226f82238 (diff)
downloadsubunit-git-fd21ba4cfc531e0906aad7b79a6b412fa778199e.tar.gz
Sort Content-Type parameters when writing details
This simplifies tests by making the output more reproducible.
-rw-r--r--python/subunit/__init__.py2
-rw-r--r--python/subunit/tests/test_test_protocol.py42
2 files changed, 10 insertions, 34 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index cf4692a..6917f42 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -821,7 +821,7 @@ class TestProtocolClient(testresult.TestResult):
if parameters:
self._stream.write(_b(";"))
param_strs = []
- for param, value in parameters.items():
+ for param, value in sorted(parameters.items()):
param_strs.append("%s=%s" % (param, value))
self._stream.write(_b(",".join(param_strs)))
self._stream.write(_b("\n%s\n" % name))
diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py
index 75a43a8..b0691f2 100644
--- a/python/subunit/tests/test_test_protocol.py
+++ b/python/subunit/tests/test_test_protocol.py
@@ -1258,23 +1258,15 @@ class TestTestProtocolClient(TestCase):
"""Test addFailure on a TestProtocolClient with details."""
self.protocol.addFailure(
self.test, details=self.sample_tb_details)
- self.assertThat([
+ self.assertEqual(
+ self.io.getvalue(),
_b(("failure: %s [ multipart\n"
"Content-Type: text/plain\n"
"something\n"
"F\r\nserialised\nform0\r\n"
"Content-Type: text/x-traceback;charset=utf8,language=python\n"
"traceback\n" + _remote_exception_str_chunked +
- "]\n") % self.test.id()),
- _b(("failure: %s [ multipart\n"
- "Content-Type: text/plain\n"
- "something\n"
- "F\r\nserialised\nform0\r\n"
- "Content-Type: text/x-traceback;language=python,charset=utf8\n"
- "traceback\n" + _remote_exception_str_chunked +
- "]\n") % self.test.id()),
- ],
- Contains(self.io.getvalue())),
+ "]\n") % self.test.id()))
def test_add_error(self):
"""Test stopTest on a TestProtocolClient."""
@@ -1290,23 +1282,15 @@ class TestTestProtocolClient(TestCase):
"""Test stopTest on a TestProtocolClient with details."""
self.protocol.addError(
self.test, details=self.sample_tb_details)
- self.assertThat([
+ self.assertEqual(
+ self.io.getvalue(),
_b(("error: %s [ multipart\n"
"Content-Type: text/plain\n"
"something\n"
"F\r\nserialised\nform0\r\n"
"Content-Type: text/x-traceback;charset=utf8,language=python\n"
"traceback\n" + _remote_exception_str_chunked +
- "]\n") % self.test.id()),
- _b(("error: %s [ multipart\n"
- "Content-Type: text/plain\n"
- "something\n"
- "F\r\nserialised\nform0\r\n"
- "Content-Type: text/x-traceback;language=python,charset=utf8\n"
- "traceback\n" + _remote_exception_str_chunked +
- "]\n") % self.test.id()),
- ],
- Contains(self.io.getvalue())),
+ "]\n") % self.test.id()))
def test_add_expected_failure(self):
"""Test addExpectedFailure on a TestProtocolClient."""
@@ -1322,23 +1306,15 @@ class TestTestProtocolClient(TestCase):
"""Test addExpectedFailure on a TestProtocolClient with details."""
self.protocol.addExpectedFailure(
self.test, details=self.sample_tb_details)
- self.assertThat([
+ self.assertEqual(
+ self.io.getvalue(),
_b(("xfail: %s [ multipart\n"
"Content-Type: text/plain\n"
"something\n"
"F\r\nserialised\nform0\r\n"
"Content-Type: text/x-traceback;charset=utf8,language=python\n"
"traceback\n" + _remote_exception_str_chunked +
- "]\n") % self.test.id()),
- _b(("xfail: %s [ multipart\n"
- "Content-Type: text/plain\n"
- "something\n"
- "F\r\nserialised\nform0\r\n"
- "Content-Type: text/x-traceback;language=python,charset=utf8\n"
- "traceback\n" + _remote_exception_str_chunked +
- "]\n") % self.test.id()),
- ],
- Contains(self.io.getvalue())),
+ "]\n") % self.test.id()))
def test_add_skip(self):
"""Test addSkip on a TestProtocolClient."""