miguelgrinberg / python-socketio

Python Socket.IO server and client
MIT License
3.96k stars 587 forks source link

Test failure with .helpers import AsyncMock #1321

Closed phls closed 5 months ago

phls commented 5 months ago

Hi, I'm building debian package with the last version, but my tests are failing.

======================================================================
ERROR: test_namespace (unittest.loader._FailedTest.test_namespace)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_namespace
Traceback (most recent call last):
  File "/usr/lib/python3.11/unittest/loader.py", line 162, in loadTestsFromName
    module = __import__(module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/autopkgtest.j7o2nD/build.NdW/src/debian/tests/async/test_namespace.py", line 6, in <module>
    from .helpers import AsyncMock, _run
ImportError: attempted relative import with no known parent package

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)
E
======================================================================
ERROR: test_pubsub_manager (unittest.loader._FailedTest.test_pubsub_manager)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_pubsub_manager
Traceback (most recent call last):
  File "/usr/lib/python3.11/unittest/loader.py", line 162, in loadTestsFromName
    module = __import__(module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/autopkgtest.j7o2nD/build.NdW/src/debian/tests/async/test_pubsub_manager.py", line 11, in <module>
    from .helpers import AsyncMock, _run
ImportError: attempted relative import with no known parent package

It seems because of: .helpers import AsyncMock, _run

But I couldn't find this module anywhere.

How can I fix that?

Thanks,

miguelgrinberg commented 5 months ago

The module is here.

I suggest you use tox to run the tests, or look at the tox configuration to learn how to create an environment that is proper for the tests. I'm not sure exactly what your mistake is, but something is wrong in your setup.