unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#40251] [PATCH] Enable tests for python-aiohttp
@ 2020-03-27 13:10 Lars-Dominik Braun
  2020-04-01 22:05 ` bug#40251: " Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Lars-Dominik Braun @ 2020-03-27 13:10 UTC (permalink / raw)
  To: 40251


[-- Attachment #1.1: Type: text/plain, Size: 310 bytes --]

Hi,

this patch-set enables tests for python-aiohttp.

gunicorn 20.0.4 fixes a critical bug that prevents using it on a guix system
and python-pytest-forked is required for the tests. We also need to cut through
a circular dependency (gunicorn<->aiohttp), thus gunicorn-bootstrap is introduced.

Cheers,
Lars


[-- Attachment #1.2: 0001-gnu-gunicorn-Update-to-20.0.4.patch --]
[-- Type: text/x-diff, Size: 1797 bytes --]

From 405d7831be08b7f00643b7b28a88ce60c2ebcd00 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
Date: Fri, 27 Mar 2020 13:55:03 +0100
Subject: [PATCH 1/3] gnu: gunicorn: Update to 20.0.4

* gnu/packages/python-web.scm (gunicorn) [version]: Update to 20.0.4
[arguments] Re-enable previously failing tests
---
 gnu/packages/python-web.scm | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/python-web.scm b/gnu/packages/python-web.scm
index 26e2fe04ec..19c08026f2 100644
--- a/gnu/packages/python-web.scm
+++ b/gnu/packages/python-web.scm
@@ -3390,14 +3390,14 @@ hard or impossible to fix in cssselect.")
 (define-public gunicorn
   (package
     (name "gunicorn")
-    (version "20.0.0")
+    (version "20.0.4")
     (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "gunicorn" version))
        (sha256
         (base32
-         "0l1zm8a0vz8ws3lkn8q9a0f93ipdzyvlf2zlwdj5xyadh6jdwsgg"))))
+         "09n6fc019bgrvph1s5h1lwhn2avcsprw6ncd203qhra3i8mvn10r"))))
     (outputs '("out" "doc"))
     (build-system python-build-system)
     (arguments
@@ -3413,11 +3413,6 @@ hard or impossible to fix in cssselect.")
            (lambda _
              (setenv "PYTHONPATH"
                      (string-append ".:" (getenv "PYTHONPATH")))
-             ;; Remove test modules failing due to libc not found due to
-             ;; section '.dynamic' not found in libc.so
-             (delete-file "tests/test_arbiter.py")
-             (delete-file "tests/test_config.py")
-             (delete-file "tests/test_sock.py")
              (invoke "pytest")))
          (add-after 'install 'install-doc
            (lambda* (#:key outputs #:allow-other-keys)
-- 
2.20.1


[-- Attachment #1.3: 0002-gnu-Add-python-pytest-forked.patch --]
[-- Type: text/x-diff, Size: 1563 bytes --]

From 02c51b326e72a501cc00216a34355ce0512ca449 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
Date: Fri, 27 Mar 2020 13:57:00 +0100
Subject: [PATCH 2/3] gnu: Add python-pytest-forked

* gnu/packages/check.scm (python-pytest-forked): New variable.
---
 gnu/packages/check.scm | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm
index 1b60b99ce1..ef0d4e3aec 100644
--- a/gnu/packages/check.scm
+++ b/gnu/packages/check.scm
@@ -1025,6 +1025,31 @@ result back.")
 timeout has been exceeded.")
     (license license:expat)))
 
+(define-public python-pytest-forked
+  (package
+    (name "python-pytest-forked")
+    (version "1.1.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "pytest-forked" version))
+       (sha256
+        (base32
+         "000i4q7my2fq4l49n8idx2c812dql97qv6qpm2vhrrn9v6g6j18q"))))
+    (build-system python-build-system)
+    (propagated-inputs
+     `(("python-pytest" ,python-pytest)))
+    (native-inputs
+     `(("python-setuptools-scm" ,python-setuptools-scm)))
+    (home-page
+     "https://github.com/pytest-dev/pytest-forked")
+    (synopsis
+     "Run tests in isolated forked subprocesses")
+    (description
+     "Pytest plugin which will run each test in a subprocess and will report if
+a test crashed the process.")
+    (license license:expat)))
+
 (define-public python-scripttest
   (package
     (name "python-scripttest")
-- 
2.20.1


[-- Attachment #1.4: 0003-gnu-python-aiohttp-Enable-tests.patch --]
[-- Type: text/x-diff, Size: 5968 bytes --]

From f3bbf527ca17d509a1c755960d0f7fc2c3daf8ea Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
Date: Fri, 27 Mar 2020 13:58:11 +0100
Subject: [PATCH 3/3] gnu: python-aiohttp: Enable tests

* gnu/packages/python-web.scm (python-aiohttp) [arguments]: Enable tests
[native-inputs] Add test dependencies [patches] Add test case patch
* gnu/packages/patches/python-aiohttp-3.6.2-no-warning-fail.patch: New file
* gnu/local.mk (dist_patch_DATA): Add it
---
 gnu/local.mk                                  |  1 +
 ...python-aiohttp-3.6.2-no-warning-fail.patch | 34 ++++++++++++++++++
 gnu/packages/python-web.scm                   | 36 +++++++++++++++++--
 3 files changed, 69 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/python-aiohttp-3.6.2-no-warning-fail.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 0a406dffa0..dc9db36c69 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1339,6 +1339,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/python-3.8-search-paths.patch		\
   %D%/packages/patches/python-3.8-fix-tests.patch		\
   %D%/packages/patches/python-CVE-2018-14647.patch		\
+  %D%/packages/patches/python-aiohttp-3.6.2-no-warning-fail.patch	\
   %D%/packages/patches/python-alembic-exceptions-cause.patch	\
   %D%/packages/patches/python-axolotl-AES-fix.patch		\
   %D%/packages/patches/python-cairocffi-dlopen-path.patch	\
diff --git a/gnu/packages/patches/python-aiohttp-3.6.2-no-warning-fail.patch b/gnu/packages/patches/python-aiohttp-3.6.2-no-warning-fail.patch
new file mode 100644
index 0000000000..6cdddefd50
--- /dev/null
+++ b/gnu/packages/patches/python-aiohttp-3.6.2-no-warning-fail.patch
@@ -0,0 +1,34 @@
+Do not fail test on runtime warning like: RuntimeWarning: coroutine 'noop2' was
+never awaited. This could be related to
+https://github.com/aio-libs/aiohttp/commit/60f01cca36b9f9d8d35dd351384eaae2f8fd0d4b,
+which does not fix this issue though.
+
+--- a/aiohttp/pytest_plugin.py	2019-10-09 18:52:31.000000000 +0200
++++ b/aiohttp/pytest_plugin.py	2020-03-05 08:35:48.230396025 +0100
+@@ -120,15 +120,6 @@
+     """
+     with warnings.catch_warnings(record=True) as _warnings:
+         yield
+-        rw = ['{w.filename}:{w.lineno}:{w.message}'.format(w=w)
+-              for w in _warnings  # type: ignore
+-              if w.category == RuntimeWarning]
+-        if rw:
+-            raise RuntimeError('{} Runtime Warning{},\n{}'.format(
+-                len(rw),
+-                '' if len(rw) == 1 else 's',
+-                '\n'.join(rw)
+-            ))
+ 
+ 
+ @contextlib.contextmanager
+--- a/tests/test_pytest_plugin.py	2020-03-05 09:26:58.502284893 +0100
++++ a/tests/test_pytest_plugin.py	2020-03-05 09:27:06.074284619 +0100
+@@ -170,7 +170,7 @@
+     expected_outcomes = (
+         {'failed': 0, 'passed': 2}
+         if IS_PYPY and bool(os.environ.get('PYTHONASYNCIODEBUG'))
+-        else {'failed': 1, 'passed': 1}
++        else {'failed': 0, 'passed': 2}
+     )
+     """Under PyPy "coroutine 'foobar' was never awaited" does not happen."""
+     result.assert_outcomes(**expected_outcomes)
diff --git a/gnu/packages/python-web.scm b/gnu/packages/python-web.scm
index 19c08026f2..3686432a1d 100644
--- a/gnu/packages/python-web.scm
+++ b/gnu/packages/python-web.scm
@@ -90,10 +90,23 @@
        (uri (pypi-uri "aiohttp" version))
        (sha256
         (base32
-         "09pkw6f1790prnrq0k8cqgnf1qy57ll8lpmc6kld09q7zw4vi6i5"))))
+         "09pkw6f1790prnrq0k8cqgnf1qy57ll8lpmc6kld09q7zw4vi6i5"))
+       (patches (search-patches "python-aiohttp-3.6.2-no-warning-fail.patch"))))
+
     (build-system python-build-system)
     (arguments
-     `(#:tests? #f))                    ;missing pytest-timeout
+     '(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-tests
+           (lambda _
+             ;; disable brotli tests, because we’re not providing that optional library
+             (substitute* "tests/test_http_parser.py"
+               (("    async def test_feed_eof_no_err_brotli")
+                "    @pytest.mark.xfail\n    async def test_feed_eof_no_err_brotli"))
+             ;; make sure the timestamp of this file is > 1990, because a few
+             ;; tests like test_static_file_if_modified_since_past_date depend on it
+             (invoke "touch" "-d" "2020-01-01" "tests/data.unknown_mime_type")
+             #t)))))
     (propagated-inputs
      `(("python-aiodns" ,python-aiodns)
        ("python-async-timeout" ,python-async-timeout)
@@ -102,6 +115,15 @@
        ("python-idna-ssl" ,python-idna-ssl)
        ("python-multidict" ,python-multidict)
        ("python-yarl" ,python-yarl)))
+    (native-inputs
+     `(("python-pytest-runner" ,python-pytest-runner)
+       ("python-pytest-xdit" ,python-pytest-xdist)
+       ("python-pytest-timeout" ,python-pytest-timeout)
+       ("python-pytest-forked" ,python-pytest-forked)
+       ("python-pytest-mock" ,python-pytest-mock)
+       ("gunicorn" ,gunicorn-bootstrap)
+       ("python-freezegun" ,python-freezegun)
+       ("python-async-generator" ,python-async-generator)))
     (home-page "https://github.com/aio-libs/aiohttp/")
     (synopsis "Async HTTP client/server framework (asyncio)")
     (description "@code{aiohttp} is an asynchronous HTTP client/server
@@ -3447,6 +3469,16 @@ various web frameworks, simply implemented, light on server resources,
 and fairly speedy.")
   (license license:expat)))
 
+;; break cyclic dependency for python-aiohttp, which depends on gunicorn for
+;; its tests
+(define-public gunicorn-bootstrap
+  (package
+    (inherit gunicorn)
+    (name "gunicorn")
+	(arguments `(#:tests? #f))
+	(properties '((hidden? . #t)))
+    (native-inputs `())))
+
 (define-public python-translation-finder
   (package
     (name "python-translation-finder")
-- 
2.20.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#40251: [PATCH] Enable tests for python-aiohttp
  2020-03-27 13:10 [bug#40251] [PATCH] Enable tests for python-aiohttp Lars-Dominik Braun
@ 2020-04-01 22:05 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2020-04-01 22:05 UTC (permalink / raw)
  To: Lars-Dominik Braun; +Cc: 40251-done

Hello,

Lars-Dominik Braun <ldb@leibniz-psychology.org> skribis:

> From 405d7831be08b7f00643b7b28a88ce60c2ebcd00 Mon Sep 17 00:00:00 2001
> From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
> Date: Fri, 27 Mar 2020 13:55:03 +0100
> Subject: [PATCH 1/3] gnu: gunicorn: Update to 20.0.4
>
> * gnu/packages/python-web.scm (gunicorn) [version]: Update to 20.0.4
> [arguments] Re-enable previously failing tests

[...]

> From 02c51b326e72a501cc00216a34355ce0512ca449 Mon Sep 17 00:00:00 2001
> From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
> Date: Fri, 27 Mar 2020 13:57:00 +0100
> Subject: [PATCH 2/3] gnu: Add python-pytest-forked
>
> * gnu/packages/check.scm (python-pytest-forked): New variable.

[...]

> From f3bbf527ca17d509a1c755960d0f7fc2c3daf8ea Mon Sep 17 00:00:00 2001
> From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
> Date: Fri, 27 Mar 2020 13:58:11 +0100
> Subject: [PATCH 3/3] gnu: python-aiohttp: Enable tests
>
> * gnu/packages/python-web.scm (python-aiohttp) [arguments]: Enable tests
> [native-inputs] Add test dependencies [patches] Add test case patch
> * gnu/packages/patches/python-aiohttp-3.6.2-no-warning-fail.patch: New file
> * gnu/local.mk (dist_patch_DATA): Add it

Applied all three patches, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-01 22:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-27 13:10 [bug#40251] [PATCH] Enable tests for python-aiohttp Lars-Dominik Braun
2020-04-01 22:05 ` bug#40251: " Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).