Date: Sunday, June 20, 2021 @ 10:59:58 Author: yan12125 Revision: 965883
python-klein: add patches to make tests green Most of patches are home-grown instead of from upstream, as upstream fixes are quite large and cannot be cleanly backported. Specifically, upstream moves test strategies from Klein to Hyperlink [1] and drop Python 2.x support [2,3]. The fix for Werkzeug 2.x in test_resource.py [3] is smaller, while it cannot be cleanly backported, either. [1] https://github.com/twisted/klein/pull/393 [2] https://github.com/twisted/klein/pull/328 [3] https://github.com/twisted/klein/pull/355 [4] https://github.com/twisted/klein/pull/499 Added: python-klein/trunk/fix-tests.diff Modified: python-klein/trunk/PKGBUILD ----------------+ PKGBUILD | 17 ++++++++----- fix-tests.diff | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 6 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2021-06-20 10:23:22 UTC (rev 965882) +++ PKGBUILD 2021-06-20 10:59:58 UTC (rev 965883) @@ -11,10 +11,17 @@ depends=(python python-attrs python-hyperlink python-incremental python-six python-tubes python-twisted python-werkzeug python-zope-interface) makedepends=(python-setuptools) -checkdepends=(python-hypothesis python-mock python-treq python-pytest) -source=("https://github.com/twisted/klein/archive/$pkgver/klein-$pkgver.tar.gz") -sha512sums=('1cba04a365fd9c7185e2f2472f617f875ee9cec41ac97940dda4a145811cefcbbe34f11e1f306656dc43d88b49e66bfcb5efb72d25283bbc8a0729b2fc5e2fca') +checkdepends=(python-hypothesis python-treq python-pytest) +source=("https://github.com/twisted/klein/archive/$pkgver/klein-$pkgver.tar.gz" + "fix-tests.diff") +sha512sums=('1cba04a365fd9c7185e2f2472f617f875ee9cec41ac97940dda4a145811cefcbbe34f11e1f306656dc43d88b49e66bfcb5efb72d25283bbc8a0729b2fc5e2fca' + 'bbe07e6c9f067265cb962654930632707d61b046709907711ceeaea8b1e691b6cee54b75b1602e2f636251e4a82dd662524dc12e6fb877ef12b7474b9e6e6874') +prepare() { + cd klein-$pkgver + patch -Np1 -i ../fix-tests.diff +} + build() { cd klein-$pkgver python setup.py build @@ -22,9 +29,7 @@ check() { cd klein-$pkgver - # klein tests are broken with treq 20.4.1 - # https://github.com/twisted/klein/issues/339 - pytest -v src/klein/test -k 'not test_customParameterValidation and not test_handlingGET' + pytest src/klein/test } package() { Added: fix-tests.diff =================================================================== --- fix-tests.diff (rev 0) +++ fix-tests.diff 2021-06-20 10:59:58 UTC (rev 965883) @@ -0,0 +1,69 @@ +diff -ur klein-20.6.0.orig/src/klein/test/_strategies.py klein-20.6.0/src/klein/test/_strategies.py +--- klein-20.6.0.orig/src/klein/test/_strategies.py 2020-06-08 10:52:04.000000000 +0800 ++++ klein-20.6.0/src/klein/test/_strategies.py 2021-06-20 18:35:54.019437139 +0800 +@@ -24,7 +24,6 @@ + + from idna import IDNAError, check_label, encode as idna_encode + +-from twisted.python.compat import _PY3, unicode + + + __all__ = () +@@ -34,8 +33,9 @@ + DrawCallable = Callable[[Callable[..., T]], T] + + +-if _PY3: ++if True: + unichr = chr ++ unicode = str + + + def idna_characters(): # pragma: no cover +diff -ur klein-20.6.0.orig/src/klein/test/test_resource.py klein-20.6.0/src/klein/test/test_resource.py +--- klein-20.6.0.orig/src/klein/test/test_resource.py 2020-06-08 10:52:04.000000000 +0800 ++++ klein-20.6.0/src/klein/test/test_resource.py 2021-06-20 18:42:53.065083517 +0800 +@@ -13,7 +13,6 @@ + from twisted.internet.defer import CancelledError, Deferred, fail, succeed + from twisted.internet.error import ConnectionLost + from twisted.internet.unix import Server +-from twisted.python.compat import _PY3, unicode + from twisted.trial.unittest import SynchronousTestCase + from twisted.web import server + from twisted.web.http_headers import Headers +@@ -34,6 +33,8 @@ + ensure_utf8_bytes, + ) + ++unicode = str ++ + + def requestMock( + path, +@@ -610,7 +611,7 @@ + request.setHeader.assert_has_calls( + [ + call(b"Content-Type", b"text/html; charset=utf-8"), +- call(b"Content-Length", b"259"), ++ call(b"Content-Length", b"258"), + call(b"Location", b"http://localhost:8080/foo/"), + ] + ) +@@ -1116,7 +1117,7 @@ + repr(_URLDecodeError(ValueError)), + ) + +- if _PY3: ++ if True: + test_urlDecodeErrorReprPy2.skip = "Only works on Py2" # type: ignore + else: + test_urlDecodeErrorReprPy3.skip = "Only works on Py3" # type: ignore +@@ -1319,7 +1320,7 @@ + self.assertIdentical(resource.ensure_utf8_bytes, ensure_utf8_bytes) + + +-if _PY3: ++if True: + import sys + + if sys.version_info >= (3, 5):
