!39 Update to 1.4.2

From: @wk333 
Reviewed-by: @lyn1001 
Signed-off-by: @lyn1001
This commit is contained in:
openeuler-ci-bot 2023-09-06 01:00:35 +00:00 committed by Gitee
commit 1d3e79e57e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 40 additions and 838 deletions

View File

@ -1,105 +0,0 @@
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index 17a970a..63c7d66 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -799,7 +799,7 @@ class TestProtocolClient(testresult.TestResult):
":param datetime: A datetime.datetime object.
"""
- time = a_datetime.astimezone(iso8601.Utc())
+ time = a_datetime.astimezone(iso8601.UTC)
self._stream.write(_b("time: %04d-%02d-%02d %02d:%02d:%02d.%06dZ\n" % (
time.year, time.month, time.day, time.hour, time.minute,
time.second, time.microsecond)))
diff --git a/python/subunit/test_results.py b/python/subunit/test_results.py
index 53c3dad..3cda44a 100644
--- a/python/subunit/test_results.py
+++ b/python/subunit/test_results.py
@@ -196,7 +196,7 @@ class AutoTimingTestResultDecorator(HookedTestResultDecorator):
time = self._time
if time is not None:
return
- time = datetime.datetime.utcnow().replace(tzinfo=iso8601.Utc())
+ time = datetime.datetime.utcnow().replace(tzinfo=iso8601.UTC)
self.decorated.time(time)
def progress(self, offset, whence):
diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py
index 7427b12..7692489 100644
--- a/python/subunit/tests/test_test_protocol.py
+++ b/python/subunit/tests/test_test_protocol.py
@@ -993,7 +993,7 @@ class TestTestProtocolServerStreamTime(unittest.TestCase):
self.assertEqual(_b(""), self.stream.getvalue())
self.assertEqual([
('time', datetime.datetime(2001, 12, 12, 12, 59, 59, 0,
- iso8601.Utc()))
+ iso8601.UTC))
], self.result._events)
@@ -1368,7 +1368,7 @@ class TestTestProtocolClient(TestCase):
def test_time(self):
# Calling time() outputs a time signal immediately.
self.protocol.time(
- datetime.datetime(2009,10,11,12,13,14,15, iso8601.Utc()))
+ datetime.datetime(2009,10,11,12,13,14,15, iso8601.UTC))
self.assertEqual(
_b("time: 2009-10-11 12:13:14.000015Z\n"),
self.io.getvalue())
diff --git a/python/subunit/tests/test_test_protocol2.py b/python/subunit/tests/test_test_protocol2.py
index bbf510e..f970ed6 100644
--- a/python/subunit/tests/test_test_protocol2.py
+++ b/python/subunit/tests/test_test_protocol2.py
@@ -218,7 +218,7 @@ class TestStreamResultToBytes(TestCase):
def test_timestamp(self):
timestamp = datetime.datetime(2001, 12, 12, 12, 59, 59, 45,
- iso8601.Utc())
+ iso8601.UTC)
result, output = self._make_result()
result.status(test_id="bar", test_status='success', timestamp=timestamp)
self.assertEqual(CONSTANT_TIMESTAMP, output.getvalue())
@@ -382,7 +382,7 @@ class TestByteStreamToStreamResult(TestCase):
def test_timestamp(self):
timestamp = datetime.datetime(2001, 12, 12, 12, 59, 59, 45,
- iso8601.Utc())
+ iso8601.UTC)
self.check_event(CONSTANT_TIMESTAMP,
'success', test_id='bar', timestamp=timestamp)
diff --git a/python/subunit/tests/test_test_results.py b/python/subunit/tests/test_test_results.py
index 44f95b3..f1a83fd 100644
--- a/python/subunit/tests/test_test_results.py
+++ b/python/subunit/tests/test_test_results.py
@@ -178,7 +178,7 @@ class TestAutoTimingTestResultDecorator(unittest.TestCase):
def test_calling_time_inhibits_automatic_time(self):
# Calling time() outputs a time signal immediately and prevents
# automatically adding one when other methods are called.
- time = datetime.datetime(2009,10,11,12,13,14,15, iso8601.Utc())
+ time = datetime.datetime(2009,10,11,12,13,14,15, iso8601.UTC)
self.result.time(time)
self.result.startTest(self)
self.result.stopTest(self)
@@ -186,7 +186,7 @@ class TestAutoTimingTestResultDecorator(unittest.TestCase):
self.assertEqual(time, self.decorated._calls[0])
def test_calling_time_None_enables_automatic_time(self):
- time = datetime.datetime(2009,10,11,12,13,14,15, iso8601.Utc())
+ time = datetime.datetime(2009,10,11,12,13,14,15, iso8601.UTC)
self.result.time(time)
self.assertEqual(1, len(self.decorated._calls))
self.assertEqual(time, self.decorated._calls[0])
diff --git a/python/subunit/v2.py b/python/subunit/v2.py
index e8a31d6..c299cab 100644
--- a/python/subunit/v2.py
+++ b/python/subunit/v2.py
@@ -49,7 +49,7 @@ FLAG_TAGS = 0x0080
FLAG_MIME_TYPE = 0x0020
FLAG_EOF = 0x0010
FLAG_FILE_CONTENT = 0x0040
-EPOCH = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=iso8601.Utc())
+EPOCH = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=iso8601.UTC)
NUL_ELEMENT = b'\0'[0]
# Contains True for types for which 'nul in thing' falsely returns false.
_nul_test_broken = {}

View File

@ -1,140 +0,0 @@
From 2dac1001c1f1a48235af10c7ccf0b36e59602ded Mon Sep 17 00:00:00 2001
From: starlet-dx <15929766099@163.com>
Date: Fri, 4 Aug 2023 17:55:15 +0800
Subject: [PATCH 1/1] Drop compatibility wrappers for memoryview in older Python versions
Refer:
https://github.com/testing-cabal/subunit/commit/f315464df26e4122758da26f40a76aa19a08ff60
---
python/subunit/tests/test_subunit_tags.py | 2 +-
python/subunit/tests/test_test_protocol2.py | 4 +--
python/subunit/v2.py | 39 ++++-----------------
3 files changed, 10 insertions(+), 35 deletions(-)
diff --git a/python/subunit/tests/test_subunit_tags.py b/python/subunit/tests/test_subunit_tags.py
index a16edc1..e62b9fe 100644
--- a/python/subunit/tests/test_subunit_tags.py
+++ b/python/subunit/tests/test_subunit_tags.py
@@ -65,7 +65,7 @@ class TestSubUnitTags(testtools.TestCase):
self.original.seek(0)
self.assertEqual(
0, subunit.tag_stream(self.original, self.filtered, ["quux"]))
- self.assertThat(reference, Contains(self.filtered.getvalue()))
+ self.assertThat(reference, Contains(bytes(self.filtered.getvalue())))
def test_remove_tag(self):
reference = BytesIO()
diff --git a/python/subunit/tests/test_test_protocol2.py b/python/subunit/tests/test_test_protocol2.py
index f970ed6..aa640e3 100644
--- a/python/subunit/tests/test_test_protocol2.py
+++ b/python/subunit/tests/test_test_protocol2.py
@@ -312,10 +312,10 @@ class TestByteStreamToStreamResult(TestCase):
source, non_subunit_name="stdout").run(result)
self.assertEqual(b'', source.read())
self.assertEqual(events, result._events)
- #- any file attachments should be byte contents [as users assume that].
+ #- any file attachments should be bytes equivalent [as users assume that].
for event in result._events:
if event[5] is not None:
- self.assertIsInstance(event[6], bytes)
+ bytes(event[6])
def check_event(self, source_bytes, test_status=None, test_id="foo",
route_code=None, timestamp=None, tags=None, mime_type=None,
diff --git a/python/subunit/v2.py b/python/subunit/v2.py
index c299cab..81be733 100644
--- a/python/subunit/v2.py
+++ b/python/subunit/v2.py
@@ -56,22 +56,6 @@ _nul_test_broken = {}
_PY3 = (sys.version_info >= (3,))
-def has_nul(buffer_or_bytes):
- """Return True if a null byte is present in buffer_or_bytes."""
- # Simple "if NUL_ELEMENT in utf8_bytes:" fails on Python 3.1 and 3.2 with
- # memoryviews. See https://bugs.launchpad.net/subunit/+bug/1216246
- buffer_type = type(buffer_or_bytes)
- broken = _nul_test_broken.get(buffer_type)
- if broken is None:
- reference = buffer_type(b'\0')
- broken = not NUL_ELEMENT in reference
- _nul_test_broken[buffer_type] = broken
- if broken:
- return b'\0' in buffer_or_bytes
- else:
- return NUL_ELEMENT in buffer_or_bytes
-
-
def read_exactly(stream, size):
"""Read exactly size bytes from stream.
@@ -391,35 +375,26 @@ class ByteStreamToStreamResult(object):
file_bytes=(error.args[0]).encode('utf8'),
mime_type="text/plain;charset=utf8")
- def _to_bytes(self, data, pos, length):
- """Return a slice of data from pos for length as bytes."""
- # memoryview in 2.7.3 and 3.2 isn't directly usable with struct :(.
- # see https://bugs.launchpad.net/subunit/+bug/1216163
- result = data[pos:pos+length]
- if type(result) is not bytes:
- return result.tobytes()
- return result
-
def _parse_varint(self, data, pos, max_3_bytes=False):
# because the only incremental IO we do is at the start, and the 32 bit
# CRC means we can always safely read enough to cover any varint, we
# can be sure that there should be enough data - and if not it is an
# error not a normal situation.
- data_0 = struct.unpack(FMT_8, self._to_bytes(data, pos, 1))[0]
+ data_0 = struct.unpack(FMT_8, data[pos:pos+1])[0]
typeenum = data_0 & 0xc0
value_0 = data_0 & 0x3f
if typeenum == 0x00:
return value_0, 1
elif typeenum == 0x40:
- data_1 = struct.unpack(FMT_8, self._to_bytes(data, pos+1, 1))[0]
+ data_1 = struct.unpack(FMT_8, data[pos+1:pos+2])[0]
return (value_0 << 8) | data_1, 2
elif typeenum == 0x80:
- data_1 = struct.unpack(FMT_16, self._to_bytes(data, pos+1, 2))[0]
+ data_1 = struct.unpack(FMT_16, data[pos+1:pos+3])[0]
return (value_0 << 16) | data_1, 3
else:
if max_3_bytes:
raise ParseError('3 byte maximum given but 4 byte value found.')
- data_1, data_2 = struct.unpack(FMT_24, self._to_bytes(data, pos+1, 3))
+ data_1, data_2 = struct.unpack(FMT_24, data[pos+1:pos+4])
result = (value_0 << 24) | data_1 << 8 | data_2
return result, 4
@@ -464,7 +439,7 @@ class ByteStreamToStreamResult(object):
# One packet could have both file and status data; the Python API
# presents these separately (perhaps it shouldn't?)
if flags & FLAG_TIMESTAMP:
- seconds = struct.unpack(FMT_32, self._to_bytes(body, pos, 4))[0]
+ seconds = struct.unpack(FMT_32, body[pos:pos+4])[0]
nanoseconds, consumed = self._parse_varint(body, pos+4)
pos = pos + 4 + consumed
timestamp = EPOCH + datetime.timedelta(
@@ -496,7 +471,7 @@ class ByteStreamToStreamResult(object):
file_name, pos = self._read_utf8(body, pos)
content_length, consumed = self._parse_varint(body, pos)
pos += consumed
- file_bytes = self._to_bytes(body, pos, content_length)
+ file_bytes = body[pos:pos+content_length]
if len(file_bytes) != content_length:
raise ParseError('File content extends past end of packet: '
'claimed %d bytes, %d available' % (
@@ -531,7 +506,7 @@ class ByteStreamToStreamResult(object):
'UTF8 string at offset %d extends past end of packet: '
'claimed %d bytes, %d available' % (pos - 2, length,
len(utf8_bytes)))
- if has_nul(utf8_bytes):
+ if NUL_ELEMENT in utf8_bytes:
raise ParseError('UTF8 string at offset %d contains NUL byte' % (
pos-2,))
try:
--
2.30.0

View File

@ -1,469 +0,0 @@
From 64970adcf1a324443d2a3bfa3b152d90561906af Mon Sep 17 00:00:00 2001
From: starlet-dx <15929766099@163.com>
Date: Thu, 7 Jul 2022 17:27:16 +0800
Subject: [PATCH 1/1] Fix tests with testtools 2.5.0
---
python/subunit/__init__.py | 8 +-
python/subunit/details.py | 6 +-
python/subunit/tests/__init__.py | 1 +
python/subunit/tests/test_chunked.py | 6 +-
python/subunit/tests/test_details.py | 6 +-
python/subunit/tests/test_subunit_filter.py | 6 +-
python/subunit/tests/test_subunit_stats.py | 6 +-
python/subunit/tests/test_test_protocol.py | 211 ++++++++++++--------
python/subunit/tests/test_test_results.py | 5 +-
9 files changed, 165 insertions(+), 90 deletions(-)
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index 17a970a..f9321e0 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -129,7 +129,11 @@ except ImportError:
from extras import safe_hasattr
from testtools import content, content_type, ExtendedToOriginalDecorator
from testtools.content import TracebackContent
-from testtools.compat import _b, _u, BytesIO, StringIO
+from testtools.compat import _b, _u
+try:
+ from testtools.compat import BytesIO, StringIO
+except ImportError:
+ from io import BytesIO, StringIO
try:
from testtools.testresult.real import _StringException
RemoteException = _StringException
@@ -817,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/details.py b/python/subunit/details.py
index 9e5e005..5105580 100644
--- a/python/subunit/details.py
+++ b/python/subunit/details.py
@@ -17,7 +17,11 @@
"""Handlers for outcome details."""
from testtools import content, content_type
-from testtools.compat import _b, BytesIO
+from testtools.compat import _b
+try:
+ from testtools.compat import BytesIO, StringIO
+except ImportError:
+ from io import BytesIO, StringIO
from subunit import chunked
diff --git a/python/subunit/tests/__init__.py b/python/subunit/tests/__init__.py
index c6599f7..4c8b2ae 100644
--- a/python/subunit/tests/__init__.py
+++ b/python/subunit/tests/__init__.py
@@ -23,6 +23,7 @@ from testscenarios import generate_scenarios
# Before the test module imports to avoid circularity.
# For testing: different pythons have different str() implementations.
_remote_exception_repr = "testtools.testresult.real._StringException"
+_remote_exception_repr_chunked = "34\r\n" + _remote_exception_repr + ": boo qux\n0\r\n"
_remote_exception_str = "Traceback (most recent call last):\ntesttools.testresult.real._StringException"
_remote_exception_str_chunked = "57\r\n" + _remote_exception_str + ": boo qux\n0\r\n"
diff --git a/python/subunit/tests/test_chunked.py b/python/subunit/tests/test_chunked.py
index 5100b32..46cf150 100644
--- a/python/subunit/tests/test_chunked.py
+++ b/python/subunit/tests/test_chunked.py
@@ -17,7 +17,11 @@
import unittest
-from testtools.compat import _b, BytesIO
+from testtools.compat import _b
+try:
+ from testtools.compat import BytesIO
+except ImportError:
+ from io import BytesIO
import subunit.chunked
diff --git a/python/subunit/tests/test_details.py b/python/subunit/tests/test_details.py
index 8605c5a..f3c70d2 100644
--- a/python/subunit/tests/test_details.py
+++ b/python/subunit/tests/test_details.py
@@ -16,7 +16,11 @@
import unittest
-from testtools.compat import _b, StringIO
+from testtools.compat import _b
+try:
+ from testtools.compat import StringIO
+except ImportError:
+ from io import StringIO
import subunit.tests
from subunit import content, content_type, details
diff --git a/python/subunit/tests/test_subunit_filter.py b/python/subunit/tests/test_subunit_filter.py
index 95aea36..baef3f6 100644
--- a/python/subunit/tests/test_subunit_filter.py
+++ b/python/subunit/tests/test_subunit_filter.py
@@ -24,7 +24,11 @@ from subunit import iso8601
import unittest
from testtools import TestCase
-from testtools.compat import _b, BytesIO
+from testtools.compat import _b
+try:
+ from testtools.compat import BytesIO
+except ImportError:
+ from io import BytesIO
from testtools.testresult.doubles import ExtendedTestResult, StreamResult
import subunit
diff --git a/python/subunit/tests/test_subunit_stats.py b/python/subunit/tests/test_subunit_stats.py
index 7c5e42d..9faf24d 100644
--- a/python/subunit/tests/test_subunit_stats.py
+++ b/python/subunit/tests/test_subunit_stats.py
@@ -18,7 +18,11 @@
import unittest
-from testtools.compat import _b, BytesIO, StringIO
+from testtools.compat import _b
+try:
+ from testtools.compat import BytesIO, StringIO
+except ImportError:
+ from io import BytesIO, StringIO
import subunit
diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py
index 7427b12..70e3564 100644
--- a/python/subunit/tests/test_test_protocol.py
+++ b/python/subunit/tests/test_test_protocol.py
@@ -16,13 +16,17 @@
import datetime
import io
-import unittest2 as unittest
import os
-import sys
import tempfile
+import unittest
+import six
from testtools import PlaceHolder, skipIf, TestCase, TestResult
-from testtools.compat import _b, _u, BytesIO
+from testtools.compat import _b, _u
+try:
+ from testtools.compat import BytesIO, StringIO
+except ImportError:
+ from io import BytesIO, StringIO
from testtools.content import Content, TracebackContent, text_content
from testtools.content_type import ContentType
try:
@@ -37,18 +41,19 @@ except ImportError:
Python27TestResult,
ExtendedTestResult,
)
-from testtools.matchers import Contains
+from testtools.matchers import Contains, Equals, MatchesAny
import subunit
from subunit.tests import (
_remote_exception_repr,
+ _remote_exception_repr_chunked,
_remote_exception_str,
_remote_exception_str_chunked,
)
import subunit.iso8601 as iso8601
-tb_prelude = "Traceback (most recent call last):\n"
+tb_prelude = "Traceback (most recent call last):\n"
def details_to_str(details):
@@ -60,7 +65,7 @@ class TestHelpers(TestCase):
fd, file_path = tempfile.mkstemp()
self.addCleanup(os.remove, file_path)
fake_file = os.fdopen(fd, 'r')
- if sys.version_info > (3, 0):
+ if six.PY3:
self.assertEqual(fake_file.buffer,
subunit._unwrap_text(fake_file))
else:
@@ -70,7 +75,7 @@ class TestHelpers(TestCase):
fd, file_path = tempfile.mkstemp()
self.addCleanup(os.remove, file_path)
fake_file = os.fdopen(fd, 'w')
- if sys.version_info > (3, 0):
+ if six.PY3:
self.assertEqual(fake_file.buffer,
subunit._unwrap_text(fake_file))
else:
@@ -152,13 +157,20 @@ class TestTestProtocolServerPipe(unittest.TestCase):
protocol.readFrom(pipe)
bing = subunit.RemotedTestCase("bing crosby")
an_error = subunit.RemotedTestCase("an error")
- self.assertEqual(
- client.errors,
- [(an_error, tb_prelude + _remote_exception_repr + '\n')])
- self.assertEqual(
- client.failures,
- [(bing, tb_prelude + _remote_exception_repr + ": "
- + details_to_str({'traceback': text_content(traceback)}) + "\n")])
+ if six.PY3:
+ self.assertEqual(client.errors,
+ [(an_error, _remote_exception_repr + '\n')])
+ self.assertEqual(
+ client.failures,
+ [(bing, _remote_exception_repr + ": "
+ + details_to_str({'traceback': text_content(traceback)}) + "\n")])
+ else:
+ self.assertEqual(client.errors,
+ [(an_error, '_StringException\n')])
+ self.assertEqual(
+ client.failures,
+ [(bing, "_StringException: "
+ + details_to_str({'traceback': text_content(traceback)}) + "\n")])
self.assertEqual(client.testsRun, 3)
def test_non_test_characters_forwarded_immediately(self):
@@ -1012,9 +1024,14 @@ class TestRemotedTestCase(unittest.TestCase):
"'A test description'>", "%r" % test)
result = unittest.TestResult()
test.run(result)
- self.assertEqual([(test, tb_prelude + _remote_exception_repr + ": "
- "Cannot run RemotedTestCases.\n\n")],
- result.errors)
+ if six.PY3:
+ self.assertEqual([(test, _remote_exception_repr + ': ' +
+ "Cannot run RemotedTestCases.\n\n")],
+ result.errors)
+ else:
+ self.assertEqual([(test, "_StringException: " +
+ "Cannot run RemotedTestCases.\n\n")],
+ result.errors)
self.assertEqual(1, result.testsRun)
another_test = subunit.RemotedTestCase("A test description")
self.assertEqual(test, another_test)
@@ -1178,6 +1195,11 @@ class TestIsolatedTestSuite(TestCase):
self.assertEqual(self.SampleTestToIsolate.TEST, False)
+# A number of these tests produce different output depending on the
+# testtools version. testtools < 2.5.0 used traceback2, which incorrectly
+# included the traceback header even for an exception with no traceback.
+# testtools 2.5.0 switched to the Python 3 standard library's traceback
+# module, which fixes this bug. See https://bugs.python.org/issue24695.
class TestTestProtocolClient(TestCase):
def setUp(self):
@@ -1233,96 +1255,121 @@ class TestTestProtocolClient(TestCase):
"""Test addFailure on a TestProtocolClient."""
self.protocol.addFailure(
self.test, subunit.RemoteError(_u("boo qux")))
- self.assertEqual(
- self.io.getvalue(),
- _b(('failure: %s [\n' + _remote_exception_str + ': boo qux\n]\n')
- % self.test.id()))
+ self.assertThat(self.io.getvalue(), MatchesAny(
+ # testtools < 2.5.0
+ Equals(_b((
+ 'failure: %s [\n' +
+ _remote_exception_str + ': boo qux\n' +
+ ']\n') % self.test.id())),
+ # testtools >= 2.5.0
+ Equals(_b((
+ 'failure: %s [\n' +
+ _remote_exception_repr + ': boo qux\n' +
+ ']\n') % self.test.id()))))
def test_add_failure_details(self):
"""Test addFailure on a TestProtocolClient with details."""
self.protocol.addFailure(
self.test, details=self.sample_tb_details)
- self.assertThat([
- _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())),
+ self.assertThat(self.io.getvalue(), MatchesAny(
+ # testtools < 2.5.0
+ Equals(_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())),
+ # testtools >= 2.5.0
+ Equals(_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_repr_chunked +
+ "]\n") % self.test.id()))))
def test_add_error(self):
"""Test stopTest on a TestProtocolClient."""
self.protocol.addError(
self.test, subunit.RemoteError(_u("phwoar crikey")))
- self.assertEqual(
- self.io.getvalue(),
- _b(('error: %s [\n' +
- _remote_exception_str + ": phwoar crikey\n"
- "]\n") % self.test.id()))
+ self.assertThat(self.io.getvalue(), MatchesAny(
+ # testtools < 2.5.0
+ Equals(_b((
+ 'error: %s [\n' +
+ _remote_exception_str + ": phwoar crikey\n"
+ "]\n") % self.test.id())),
+ # testtools >= 2.5.0
+ Equals(_b((
+ 'error: %s [\n' +
+ _remote_exception_repr + ": phwoar crikey\n"
+ "]\n") % self.test.id()))))
def test_add_error_details(self):
"""Test stopTest on a TestProtocolClient with details."""
self.protocol.addError(
self.test, details=self.sample_tb_details)
- self.assertThat([
- _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())),
+ self.assertThat(self.io.getvalue(), MatchesAny(
+ # testtools < 2.5.0
+ Equals(_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())),
+ # testtools >= 2.5.0
+ Equals(_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_repr_chunked +
+ "]\n") % self.test.id()))))
def test_add_expected_failure(self):
"""Test addExpectedFailure on a TestProtocolClient."""
self.protocol.addExpectedFailure(
self.test, subunit.RemoteError(_u("phwoar crikey")))
- self.assertEqual(
- self.io.getvalue(),
- _b(('xfail: %s [\n' +
- _remote_exception_str + ": phwoar crikey\n"
- "]\n") % self.test.id()))
+ self.assertThat(self.io.getvalue(), MatchesAny(
+ # testtools < 2.5.0
+ Equals(_b((
+ 'xfail: %s [\n' +
+ _remote_exception_str + ": phwoar crikey\n"
+ "]\n") % self.test.id())),
+ # testtools >= 2.5.0
+ Equals(_b((
+ 'xfail: %s [\n' +
+ _remote_exception_repr + ": phwoar crikey\n"
+ "]\n") % self.test.id()))))
def test_add_expected_failure_details(self):
"""Test addExpectedFailure on a TestProtocolClient with details."""
self.protocol.addExpectedFailure(
self.test, details=self.sample_tb_details)
- self.assertThat([
- _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())),
+ self.assertThat(self.io.getvalue(), MatchesAny(
+ # testtools < 2.5.0
+ Equals(_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())),
+ # testtools >= 2.5.0
+ Equals(_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_repr_chunked +
+ "]\n") % self.test.id()))))
def test_add_skip(self):
"""Test addSkip on a TestProtocolClient."""
diff --git a/python/subunit/tests/test_test_results.py b/python/subunit/tests/test_test_results.py
index 44f95b3..add30bb 100644
--- a/python/subunit/tests/test_test_results.py
+++ b/python/subunit/tests/test_test_results.py
@@ -20,7 +20,10 @@ import sys
import unittest
from testtools import TestCase
-from testtools.compat import StringIO
+try:
+ from testtools.compat import StringIO
+except ImportError:
+ from io import StringIO
from testtools.content import (
text_content,
TracebackContent,
--
2.30.0

Binary file not shown.

BIN
subunit-1.4.2.tar.gz Normal file

Binary file not shown.

View File

@ -1,13 +0,0 @@
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index 63c7d66..e735437 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -556,7 +556,7 @@ class TestProtocolServer(object):
def _handleTime(self, offset, line):
# Accept it, but do not do anything with it yet.
try:
- event_time = iso8601.parse_date(line[offset:-1])
+ event_time = iso8601.parse_date(line[offset:-1].decode('utf8'))
except TypeError:
raise TypeError(_u("Failed to parse %r, got %r")
% (line, sys.exec_info[1]))

View File

@ -1,45 +0,0 @@
--- COPYING.orig 2018-03-24 08:22:44.000000000 -0600
+++ COPYING 2018-07-03 15:07:50.241733503 -0600
@@ -29,8 +29,6 @@ Code that has been incorporated into Sub
naturally be under its own license, and will retain that license.
A known list of such code is maintained here:
-* The python/iso8601 module by Michael Twomey, distributed under an MIT style
- licence - see python/iso8601/LICENSE for details.
* The runtests.py and python/subunit/tests/TestUtil.py module are GPL test
support modules. They are not installed by Subunit - they are only ever
used on the build machine. Copyright 2004 Canonical Limited.
--- Makefile.am.orig 2018-03-24 08:22:44.000000000 -0600
+++ Makefile.am 2018-07-03 15:08:08.386499408 -0600
@@ -16,11 +16,6 @@ EXTRA_DIST = \
perl/lib/Subunit.pm \
perl/lib/Subunit/Diff.pm \
perl/subunit-diff \
- python/iso8601/LICENSE \
- python/iso8601/README \
- python/iso8601/README.subunit \
- python/iso8601/setup.py \
- python/iso8601/test_iso8601.py \
python/subunit/tests/__init__.py \
python/subunit/tests/sample-script.py \
python/subunit/tests/sample-two-script.py \
@@ -78,7 +73,6 @@ pkgpython_PYTHON = \
python/subunit/chunked.py \
python/subunit/details.py \
python/subunit/filters.py \
- python/subunit/iso8601.py \
python/subunit/progress_model.py \
python/subunit/run.py \
python/subunit/v2.py \
--- README.rst.orig 2018-03-24 08:22:44.000000000 -0600
+++ README.rst 2018-07-03 15:08:21.114335195 -0600
@@ -15,9 +15,6 @@
See the COPYING file for full details on the licensing of Subunit.
- subunit reuses iso8601 by Michael Twomey, distributed under an MIT style
- licence - see python/iso8601/LICENSE for details.
-
Subunit
-------

View File

@ -1,20 +1,24 @@
Name: subunit
Version: 1.4.0
Release: 3
Version: 1.4.2
Release: 1
Summary: C bindings for subunit
License: ASL 2.0 or BSD
License: Apache-2.0 OR BSD-3-Clause
URL: https://launchpad.net/subunit
Source0: https://launchpad.net/subunit/trunk/%{version}/+download/%{name}-%{version}.tar.gz
Patch0: %{name}-unbundle-iso8601.patch
Patch1: %{name}-decode-binary-to-unicode.patch
Patch2: 0001-port-to-python-iso8601-0.1.14.patch
Patch3: Fix-tests-with-testtools-2.5.0.patch
Patch4: Drop-compatibility-wrappers-for-memoryview-in-older.patch
BuildRequires: check-devel cppunit-devel gcc-c++ libtool perl-generators make
BuildRequires: perl(ExtUtils::MakeMaker) pkgconfig
BuildRequires: python3-devel python3-docutils python3-extras python3-fixtures python3-iso8601
BuildRequires: python3-hypothesis python3-setuptools python3-testscenarios
BuildRequires: gcc-c++
BuildRequires: libtool
BuildRequires: make
BuildRequires: perl-generators
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: pkgconfig
BuildRequires: pkgconfig(cppunit)
BuildRequires: python3-devel
BuildRequires: python3-pip
BuildRequires: python3-wheel
BuildRequires: python3-testtools >= 1.8.0
BuildRequires: python3-testscenarios
BuildRequires: pkgconfig(check)
%description
Subunit C bindings. See the python-subunit package for test processing
functionality.
@ -55,10 +59,11 @@ Subunit shell bindings. See the python-subunit package for test
processing functionality.
%package -n python3-%{name}
# The bundled iso8601 library is MIT licensed
License: (Apache-2.0 OR BSD-3-Clause) AND MIT
Summary: Streaming protocol for test results
BuildArch: noarch
Requires: python3-extras python3-iso8601 python3-testtools >= 1.8.0
%{?python_provide:%python_provide python3-%{name}}
Provides: bundled(python3-iso8601) = 0.1.4
%description -n python3-%{name}
Subunit is a streaming protocol for test results. The protocol is a
binary encoding that is easily generated and parsed. By design all the
@ -83,9 +88,7 @@ A number of useful things can be done easily with subunit:
Summary: Test code for the python 3 subunit bindings
BuildArch: noarch
Requires: python3-%{name} = %{version}-%{release} %{name}-filters = %{version}-%{release}
%{?python_provide:%python_provide python3-%{name}-test}
Obsoletes: python3-%{name}-test < 1.3.0-9
Provides: python3-%{name}-test = %{version}-%{release}
%description -n python3-%{name}-test
%{summary}.
@ -105,45 +108,22 @@ Subunit C bindings in a static library, for building statically linked
test cases.
%prep
%autosetup -n %{name}-%{version} -S git
%autosetup -n %{name}-%{version} -p1
fixtimestamp() {
touch -r $1.orig $1
rm $1.orig
}
for filt in filters/*; do
sed 's,/usr/bin/env ,/usr/bin/,' $filt > ${filt}.new
sed -i 's,\(%{_bindir}/python\),\13,' ${filt}.new
chmod 0755 ${filt}.new
touch -r $filt ${filt}.new
mv -f ${filt}.new $filt
done
sed "/^tests_LDADD/ilibcppunit_subunit_la_LIBADD = -lcppunit libsubunit.la\n" \
-i Makefile.am
for fil in $(grep -Frl "%{_bindir}/env python"); do
sed -i.orig 's,%{_bindir}/env python,%{_bindir}/python2,' $fil
sed -i.orig 's,%{_bindir}/env python3,%{_bindir}/python3,' $fil
fixtimestamp $fil
done
autoreconf -fi
cp -a ../%{name}-%{version} ../python3
mv ../python3 .
pushd python3
for fil in $(grep -Frl "%{_bindir}/python2"); do
sed -i.orig 's,\(%{_bindir}/python\)2,\13,' $fil
fixtimestamp $fil
done
ln -f -s %{python3_sitelib}/iso8601/iso8601.py python/subunit/iso8601.py
popd
%build
export INSTALLDIRS=perl
%configure --enable-shared --enable-static
sed -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' \
-e 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' \
-e 's|CC=.g..|& -Wl,--as-needed|' \
-i libtool
make %{?_smp_mflags}
pushd python3
export INSTALLDIRS=perl
# Build for python3
export PYTHON=%{_bindir}/python3
%configure --enable-shared --enable-static
sed -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' \
@ -151,50 +131,39 @@ sed -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' \
-e 's|CC=.g..|& -Wl,--as-needed|' \
-i libtool
make %{?_smp_mflags}
%py3_build
popd
%pyproject_build
%install
pushd python3
%py3_install
%pyproject_install
chmod 0755 %{buildroot}%{python3_sitelib}/%{name}/run.py
chmod 0755 %{buildroot}%{python3_sitelib}/%{name}/tests/sample-script.py
chmod 0755 %{buildroot}%{python3_sitelib}/%{name}/tests/sample-two-script.py
sed -i "s|root, 'filters'|'/usr', 'bin'|" \
%{buildroot}%{python3_sitelib}/%{name}/tests/test_subunit_filter.py
ln -f -s %{python3_sitelib}/iso8601/iso8601.py \
%{buildroot}%{python3_sitelib}/subunit/iso8601.py
for fil in iso8601.cpython-37.opt-1.pyc iso8601.cpython-37.pyc; do
ln -f -s %{python3_sitelib}/iso8601/__pycache__/$fil \
%{buildroot}%{python3_sitelib}/subunit/__pycache__/$fil
done
popd
%make_install INSTALL="%{_bindir}/install -p"
mkdir -p %{buildroot}%{_sysconfdir}/profile.d
cp -p shell/share/%{name}.sh %{buildroot}%{_sysconfdir}/profile.d
rm -f %{buildroot}%{_libdir}/*.la
mkdir -p %{buildroot}%{perl_vendorlib}
mv %{buildroot}%{perl_privlib}/Subunit* %{buildroot}%{perl_vendorlib}
rm -fr %{buildroot}%{perl_archlib}
chmod 0755 %{buildroot}%{_bindir}/subunit-diff
chmod 0755 %{buildroot}%{python3_sitelib}/%{name}/filter_scripts/*.py
chmod 0644 %{buildroot}%{python3_sitelib}/%{name}/filter_scripts/__init__.py
chmod 0755 %{buildroot}%{python3_sitelib}/%{name}/tests/sample-script.py
chmod 0755 %{buildroot}%{python3_sitelib}/%{name}/tests/sample-two-script.py
touch -r c/include/%{name}/child.h %{buildroot}%{_includedir}/%{name}/child.h
touch -r c++/SubunitTestProgressListener.h \
%{buildroot}%{_includedir}/%{name}/SubunitTestProgressListener.h
touch -r perl/subunit-diff %{buildroot}%{_bindir}/subunit-diff
for fil in filters/*; do
touch -r $fil %{buildroot}%{_bindir}/$(basename $fil)
done
%check
pushd python3
export LD_LIBRARY_PATH=$PWD/.libs
export PYTHON=%{__python3}
make check
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} -c "import subunit.iso8601"
popd
%ldconfig_scriptlets
%ldconfig_scriptlets cppunit
%files
%doc NEWS README.rst
@ -230,7 +199,7 @@ popd
%files -n python3-%{name}
%license Apache-2.0 BSD COPYING
%{python3_sitelib}/%{name}/
%{python3_sitelib}/python_%{name}-%{version}-*.egg-info
%{python3_sitelib}/python_%{name}-%{version}.dist-info/
%exclude %{python3_sitelib}/%{name}/tests/
%files -n python3-%{name}-test
@ -244,6 +213,11 @@ popd
%exclude %{_bindir}/%{name}-diff
%changelog
* Tue Sep 05 2023 wangkai <13474090681@163.com> - 1.4.2-1
- Update to 1.4.2
- Use pyproject to compile package
- Modify iso8601 to bundle
* Fri Aug 04 2023 yaoxin <yao_xin001@hoperun.com> - 1.4.0-3
- Fix test failure caused by python update to 3.11