Skip to content

Commit

Permalink
Update code and tests to python-subunit >= 1.4.3. (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Sep 29, 2023
1 parent 128d3b4 commit 1b2dbcf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
6.2 (unreleased)
================

- Update code and tests to ``python-subunit >= 1.4.3`` thus requiring at least
this version.


6.1 (2023-08-26)
================
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
EXTRAS_REQUIRE = {
'test': TESTS_REQUIRE,
'subunit': [
'python-subunit >= 0.0.11',
'python-subunit >= 1.4.3',
'testtools >= 0.9.30',
],
'docs': [
Expand Down
6 changes: 3 additions & 3 deletions src/zope/testrunner/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ def id(self):
# dependency on subunit.
try:
import subunit
from subunit.iso8601 import Utc
from iso8601 import UTC
subunit.StreamResultToBytes
except (ImportError, AttributeError):
subunit = None
Expand Down Expand Up @@ -880,7 +880,7 @@ class SubunitOutputFormatter:

def __init__(self, options, stream=None):
if subunit is None:
raise Exception('Requires subunit 0.0.11 or better')
raise Exception('Requires python-subunit 1.4.3 or better')
if testtools is None:
raise Exception('Requires testtools 0.9.30 or better')
self.options = options
Expand All @@ -893,7 +893,7 @@ def __init__(self, options, stream=None):
# Used to track the last layer that was set up or torn down. Either
# None or (layer_name, last_touched_time).
self._last_layer = None
self.UTC = Utc()
self.UTC = UTC
# Content types used in the output.
self.TRACEBACK_CONTENT_TYPE = ContentType(
'text', 'x-traceback', {'language': 'python', 'charset': 'utf8'})
Expand Down
4 changes: 2 additions & 2 deletions src/zope/testrunner/tests/testrunner-subunit-v2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For easier doctesting, we use a helper that summarizes the output.
... eof=False, mime_type=None, route_code=None,
... timestamp=None):
... if (test_id, file_name) == self._last_file:
... self.stream.write(file_bytes.decode('utf-8', 'replace'))
... self.stream.write(file_bytes.tobytes().decode('utf-8', 'replace'))
... return
... elif self._last_file is not None:
... self.stream.write('\n')
Expand All @@ -49,7 +49,7 @@ For easier doctesting, we use a helper that summarizes the output.
... self.stream.write('\n')
... if file_name is not None:
... self.stream.write('%s (%s)\n' % (file_name, mime_type))
... self.stream.write(file_bytes.decode('utf-8', 'replace'))
... self.stream.write(file_bytes.tobytes().decode('utf-8', 'replace'))
... self._last_file = (test_id, file_name)
... self.stream.flush()

Expand Down

0 comments on commit 1b2dbcf

Please sign in to comment.