Subject: [PATCH v2 3/3] gnu: python-falcon: Fix tests.

From: Ricardo Wurmus <[email-masked]>
Date: Mon, 2 Dec 2024 18:01:42 +0100

* gnu/packages/python-web.scm (python-falcon)[native-inputs]: Add
python-orjson.
[arguments]: Do not patch test file; respect test-flags in custom 'check
phase; provide test-flags to ignore examples and benchmarks.
[build-system]: Use pyproject-build-system.

Change-Id: Ic173e2d940a2bb9c7f81ea3e70475f8bfff36dfb
---
 gnu/packages/python-web.scm | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/gnu/packages/python-web.scm b/gnu/packages/python-web.scm
index 2137cc42536..fb43c9b0a06 100644
--- a/gnu/packages/python-web.scm
+++ b/gnu/packages/python-web.scm
@@ -1176,17 +1176,19 @@ (define-public python-falcon
        (sha256
         (base32
          "17k31d8avl63xsr6fzvmkxcsm7gnz5dqpgsz65psm1lpc38c79k3"))))
-    (build-system python-build-system)
+    (build-system pyproject-build-system)
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
+     (list
+      #:test-flags
+      '(list "--ignore-glob=examples/*" "--ignore-glob=bench/*" "tests")
+      #:phases
+      '(modify-phases %standard-phases
+         (add-before 'check 'set-HOME
+           (lambda _ (setenv "HOME" "/tmp")))
          (replace 'check
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             ;; Skip orjson, which requires rust to build.
-             (substitute* "tests/test_media_handlers.py"
-               (("== 'CPython") "!= 'CPython"))
-             (setenv "HOME" "/tmp")
-             (invoke "pytest" "-vv" "tests"))))))
+           (lambda* (#:key tests? test-flags #:allow-other-keys)
+             (when tests?
+               (apply invoke "pytest" "-vv" test-flags)))))))
     (propagated-inputs
      (list python-mimeparse))
     (native-inputs
@@ -1197,6 +1199,7 @@ (define-public python-falcon
            python-httpx
            python-mujson
            python-msgpack
+           python-orjson
            python-pecan
            python-pillow
            python-pytest
-- 
2.46.0