Subject: [bug#34515] [PATCH 10/13] gnu: Add python-autobahn.

From: Leo Famulari <[email-masked]>
Date: Mon, 18 Feb 2019 23:23:49 -0500

On Mon, Feb 18, 2019 at 09:27:50AM +0100, Ricardo Wurmus wrote:
> Leo Famulari <[email-masked]> writes:
> > * gnu/packages/python-web.scm (python-autobahn): New variable.
> […]
> > +    (arguments
> > +     `(#:tests? #f)) ; fail mysteriously
> 
> Mysteriously, eh?  Do you have any more information about this that
> might help us debug this?

Basically, the tests quit early after several errors like this:

------
______ ERROR collecting build/lib/autobahn/nvx/test/test_utf8validator.py ______
import file mismatch:
imported module 'test_utf8validator' has this __file__ attribute:
  /tmp/guix-build-python-autobahn-19.2.1.drv-0/autobahn-19.2.1/autobahn/nvx/test/test_utf8validator.py
which is not the same as the test file we want to collect:
  /tmp/guix-build-python-autobahn-19.2.1.drv-0/autobahn-19.2.1/build/lib/autobahn/nvx/test/test_utf8validator.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
------

I don't fully understand the issue but it's discussed in the pytest bug
tracker as a general issue:

https://github.com/pytest-dev/pytest/issues/529

What do you think? My opinion is that the test suite is broken.

The failure can be reproduced by adding this patch:

diff --git a/gnu/packages/python-web.scm b/gnu/packages/python-web.scm
index c58f358c63..e4ca630498 100644
--- a/gnu/packages/python-web.scm
+++ b/gnu/packages/python-web.scm
@@ -3014,7 +3014,23 @@ high level API for making HTTP requests when using Twisted.")
           "1mm7j24ls01c7jb1ad5p5cpyxvzgydiyf8b04ihykh2v8g98j0x7"))))
     (build-system python-build-system)
     (arguments
-     `(#:tests? #f)) ; fail mysteriously
+     `(#:tests? #t
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'adjust-tests
+           (lambda _
+             ;; This variable chooses whether to use Twisted or
+             ;; asyncio for the tests.
+             (setenv "USE_TWISTED" "true")
+             ;; The require an old pytest because they aim to support
+             ;; Python 3.3.
+             (substitute* "setup.py"
+               (("pytest>=2.8.6,<3.3.0")
+                 "pytest"))
+             #t)))))
+    (native-inputs
+     `(("python-mock" ,python-mock)
+       ("python-pytest" ,python-pytest)))
     (propagated-inputs
      `(("python-cffi" ,python-cffi)
        ("python-twisted" ,python-twisted)