Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anyio/3.3.0: failures running tests #368

Closed
sandrotosi opened this issue Sep 8, 2021 · 30 comments
Closed

anyio/3.3.0: failures running tests #368

sandrotosi opened this issue Sep 8, 2021 · 30 comments

Comments

@sandrotosi
Copy link

Hello,
i'm packaging the latest version of anyio for Debian, and we are seeing some errors running tests

first we get this:

======================================= test session starts ========================================
platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-0.13.0
rootdir: /build/python-anyio-3.3.0, configfile: pyproject.toml
plugins: mock-3.6.1
collected 6 items / 19 errors                                                                      

============================================== ERRORS ==============================================
________________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_compat.py _________________
'anyio' not found in `markers` configuration option
_______________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_debugging.py _______________
'anyio' not found in `markers` configuration option
_______________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_eventloop.py _______________
'anyio' not found in `markers` configuration option
________________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_fileio.py _________________
'anyio' not found in `markers` configuration option
______________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_from_thread.py ______________
'anyio' not found in `markers` configuration option
_______________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_lowlevel.py ________________
'anyio' not found in `markers` configuration option
________________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_signals.py ________________
'anyio' not found in `markers` configuration option
________________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_sockets.py ________________
'anyio' not found in `markers` configuration option
_____________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_subprocesses.py ______________
'anyio' not found in `markers` configuration option
____________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_synchronization.py ____________
'anyio' not found in `markers` configuration option
______________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_taskgroups.py _______________
'anyio' not found in `markers` configuration option
______________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_to_process.py _______________
'anyio' not found in `markers` configuration option
_______________ ERROR collecting .pybuild/cpython3_3.9/build/tests/test_to_thread.py _______________
'anyio' not found in `markers` configuration option
___________ ERROR collecting .pybuild/cpython3_3.9/build/tests/streams/test_buffered.py ____________
'anyio' not found in `markers` configuration option
_____________ ERROR collecting .pybuild/cpython3_3.9/build/tests/streams/test_file.py ______________
'anyio' not found in `markers` configuration option
____________ ERROR collecting .pybuild/cpython3_3.9/build/tests/streams/test_memory.py _____________
'anyio' not found in `markers` configuration option
____________ ERROR collecting .pybuild/cpython3_3.9/build/tests/streams/test_stapled.py ____________
'anyio' not found in `markers` configuration option
_____________ ERROR collecting .pybuild/cpython3_3.9/build/tests/streams/test_text.py ______________
'anyio' not found in `markers` configuration option
______________ ERROR collecting .pybuild/cpython3_3.9/build/tests/streams/test_tls.py ______________
'anyio' not found in `markers` configuration option
!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 19 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================== 19 errors in 0.14s ========================================

but adding a pytest.ini file with:

[pytest]
markers =
  anyio
  network

it goes a bit better but still fails with:

======================================= test session starts ========================================
platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-0.13.0
rootdir: /build/python-anyio-3.3.0/.pybuild/cpython3_3.9/build, configfile: pytest.ini
plugins: mock-3.6.1
collected 377 items / 2 errors / 375 selected                                                      

============================================== ERRORS ==============================================
____________________________ ERROR collecting tests/test_taskgroups.py _____________________________
In test_start_native_host_cancelled: function uses no argument 'anyio_backend'
_____________________________ ERROR collecting tests/test_to_thread.py _____________________________
In test_asyncio_cancel_native_task: function uses no argument 'anyio_backend'
===================================== short test summary info ======================================
ERROR tests/test_taskgroups.py
ERROR tests/test_to_thread.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================== 2 errors in 0.31s =========================================

which is indeed correct, since those 2 functions dont use the parametrize parameter.

any idea how to address the last issue? should you also add a pytest.ini to the repo? (i noticed there's a reference in pyproject.toml, but Debian doesnt use poetry yet, and even when copying those options, tests fail with a traceback in pytest)

thanks!

@agronholm
Copy link
Owner

This happens when you don't install the project before running tests. You should either use tox or create a virtualenv and install the project there and only run tests. Otherwise the pytest plugin and the markers do not work.

@sandrotosi
Copy link
Author

we do run tests from the install directory, if that wasnt the case we'd get a "no module named anyio" or something similar.

this is a clear issue with how the parametrize decorator is used, or do you think otherwise? if so, please elaborate

@agronholm
Copy link
Owner

Here is a sample output from a pytest run:

$ pytest
================================================= test session starts ==================================================
platform linux -- Python 3.6.14, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
rootdir: /home/alex/workspace/anyio, configfile: pyproject.toml, testpaths: tests
plugins: hypothesis-6.1.1, mock-3.6.1, anyio-3.3.0.post13
collected 1245 items                                                                                                   

tests/test_compat.py .......................................................................................     [  6%]
tests/test_debugging.py .......................                                                                  [  8%]
tests/test_eventloop.py .........                                                                                [  9%]
tests/test_fileio.py .........................s...........s..................................................... [ 16%]
......sss...............................................................                                         [ 22%]
tests/test_from_thread.py .............................................................................          [ 28%]
tests/test_lowlevel.py ...........................                                                               [ 31%]
tests/test_pytest_plugin.py ......                                                                               [ 31%]
tests/test_signals.py .........                                                                                  [ 32%]
tests/test_sockets.py .......................................................................................... [ 39%]
................................................................................................................ [ 48%]
................................................................................................................ [ 57%]
...............                                                                                                  [ 58%]
tests/test_subprocesses.py ..................                                                                    [ 60%]
tests/test_synchronization.py .................................................................................. [ 66%]
.................                                                                                                [ 68%]
tests/test_taskgroups.py ....................................................................................... [ 75%]
.........................................................................................s                       [ 82%]
tests/test_to_process.py .....................                                                                   [ 83%]
tests/test_to_thread.py ........................                                                                 [ 85%]
tests/streams/test_buffered.py ............                                                                      [ 86%]
tests/streams/test_file.py ..............................                                                        [ 89%]
tests/streams/test_memory.py .................................................................                   [ 94%]
tests/streams/test_stapled.py ..................                                                                 [ 95%]
tests/streams/test_text.py ...............                                                                       [ 97%]
tests/streams/test_tls.py ....................................                                                   [100%]

=============================================== short test summary info ================================================
SKIPPED [1] tests/test_fileio.py:119: Drive only makes sense on Windows
SKIPPED [1] tests/test_fileio.py:159: Only makes sense on Windows
SKIPPED [3] tests/test_fileio.py:318: os.lchmod() is not available
SKIPPED [1] tests/test_taskgroups.py:967: Cancel messages are only supported on py3.9+
=========================================== 1239 passed, 6 skipped in 30.28s ===========================================

The notable difference here is the lack of the anyio plugin in your own output which explains the errors. The anyio pytest plugin consumes the anyio_backend parameter which would otherwise lead to an error.

Could you tell me the exact steps you are taking when installing anyio and running the tests?

@sandrotosi
Copy link
Author

sandrotosi commented Sep 8, 2021

the lack of output is because it's still in the collecting phase, so pytest has not run any test, as you can see from:

Interrupted: 2 errors during collection

I'm not at my workstation right now, so i'll post the steps later.

The other differences i can see are:

  • you're running pytest 6.2.2 while i'm running 6.2.5; nothing in the changelog suggest this may cause a problem
  • you're running it from the rootdir of the git repo, while i'm running from where setup.py install installs it
  • your run uses pyproject.toml to configure pytest, while i'm using the pytest.ini file i pasted here

@agronholm
Copy link
Owner

I should point out that setup.py install is deprecated; you should use pip install . to install a Python project. I have at least one project that doesn't even have a setup.py anymore. I'm not sure if that's the ultimate cause of this, but it does appear that Python does not see the installed entry point for the anyio pytest plugin, causing the test run to fail.

@sandrotosi
Copy link
Author

I should point out that setup.py install is deprecated; you should use pip install . to install a Python project. I have at least one project that doesn't even have a setup.py anymore. I'm not sure if that's the ultimate cause of this,

i'm afraid that wont fly for Debian: we dont use and likely (i;m not sure we ever discussed this) wont use pip to build packages.

but it does appear that Python does not see the installed entry point for the anyio pytest plugin, causing the test run to fail.

can you explain how you came to this conclusion? the error is

In test_start_native_host_cancelled: function uses no argument 'anyio_backend'
In test_asyncio_cancel_native_task: function uses no argument 'anyio_backend'

which is factually correct: those functions do not use anyio_backend from parametrize, as visible here: https://github.com/agronholm/anyio/blob/master/tests/test_to_thread.py#L135-L148 , please note the absence of any argument to test_asyncio_cancel_native_task()

@agronholm
Copy link
Owner

i'm afraid that wont fly for Debian: we dont use and likely (i;m not sure we ever discussed this) wont use pip to build packages.

Then what do you plan to do with newer projects that are either based on flit or poetry or don't have a setup.py?

which is factually correct: those functions do not use anyio_backend from parametrize, as visible here: https://github.com/agronholm/anyio/blob/master/tests/test_to_thread.py#L135-L148 , please note the absence of any argument to test_asyncio_cancel_native_task()

The AnyIO pytest plugin hijacks the test call operation and only passes arguments to the test function that is has actually declared, here: https://github.com/agronholm/anyio/blob/master/src/anyio/pytest_plugin.py#L125-L127

Which version of setuptools are you using btw? That might yield useful clues.

@sandrotosi
Copy link
Author

i'm afraid that wont fly for Debian: we dont use and likely (i;m not sure we ever discussed this) wont use pip to build packages.

Then what do you plan to do with newer projects that are either based on flit or poetry or don't have a setup.py?

this is a bit orthogonal to this discussion, but in that case we're gonna use flit or poetry, or convert pyproject.toml to setup.py (which i already had to do a handful of time since poetry is not part of Debian yet), but again i dont think this matters here, since anyio still provides setup.py.

which is factually correct: those functions do not use anyio_backend from parametrize, as visible here: https://github.com/agronholm/anyio/blob/master/tests/test_to_thread.py#L135-L148 , please note the absence of any argument to test_asyncio_cancel_native_task()

The AnyIO pytest plugin hijacks the test call operation and only passes arguments to the test function that is has actually declared, here: https://github.com/agronholm/anyio/blob/master/src/anyio/pytest_plugin.py#L125-L127

Which version of setuptools are you using btw? That might yield useful clues.

we have 52.0.0 for setuptools and 6.0.1 for setuptools-scm.

I did more tests and here is what i get when i run pytest from the top-level dir of the project:

root@zion:/build/python-anyio-3.3.0# COLUMNS=100 pytest-3 
======================================= test session starts ========================================
platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-0.13.0
rootdir: /build/python-anyio-3.3.0, configfile: pyproject.toml, testpaths: tests
plugins: mock-3.6.1
collected 0 items / 20 errors                                                                      

============================================== ERRORS ==============================================
______________________________ ERROR collecting tests/test_compat.py _______________________________
ImportError while importing test module '/build/python-anyio-3.3.0/tests/test_compat.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_compat.py:9: in <module>
    from anyio import (
E   ModuleNotFoundError: No module named 'anyio'

... etc...

as expected, the module is not found and you get a nice ModuleNotFoundError.

now if i set PYThONPATH to the build directory:

root@zion:/build/python-anyio-3.3.0# COLUMNS=100 PYTHONPATH=.pybuild/cpython3_3.9/build/  pytest-3 
======================================= test session starts ========================================
platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-0.13.0
rootdir: /build/python-anyio-3.3.0, configfile: pyproject.toml, testpaths: tests
plugins: mock-3.6.1
collected 6 items / 19 errors                                                                      

============================================== ERRORS ==============================================
______________________________ ERROR collecting tests/test_compat.py _______________________________
'anyio' not found in `markers` configuration option
_____________________________ ERROR collecting tests/test_debugging.py _____________________________
'anyio' not found in `markers` configuration option
_____________________________ ERROR collecting tests/test_eventloop.py _____________________________
'anyio' not found in `markers` configuration option
______________________________ ERROR collecting tests/test_fileio.py _______________________________
'anyio' not found in `markers` configuration option
____________________________ ERROR collecting tests/test_from_thread.py ____________________________
'anyio' not found in `markers` configuration option
_____________________________ ERROR collecting tests/test_lowlevel.py ______________________________
'anyio' not found in `markers` configuration option
______________________________ ERROR collecting tests/test_signals.py ______________________________
'anyio' not found in `markers` configuration option
______________________________ ERROR collecting tests/test_sockets.py ______________________________
'anyio' not found in `markers` configuration option
___________________________ ERROR collecting tests/test_subprocesses.py ____________________________
'anyio' not found in `markers` configuration option
__________________________ ERROR collecting tests/test_synchronization.py __________________________
'anyio' not found in `markers` configuration option
____________________________ ERROR collecting tests/test_taskgroups.py _____________________________
'anyio' not found in `markers` configuration option
____________________________ ERROR collecting tests/test_to_process.py _____________________________
'anyio' not found in `markers` configuration option
_____________________________ ERROR collecting tests/test_to_thread.py _____________________________
'anyio' not found in `markers` configuration option
_________________________ ERROR collecting tests/streams/test_buffered.py __________________________
'anyio' not found in `markers` configuration option
___________________________ ERROR collecting tests/streams/test_file.py ____________________________
'anyio' not found in `markers` configuration option
__________________________ ERROR collecting tests/streams/test_memory.py ___________________________
'anyio' not found in `markers` configuration option
__________________________ ERROR collecting tests/streams/test_stapled.py __________________________
'anyio' not found in `markers` configuration option
___________________________ ERROR collecting tests/streams/test_text.py ____________________________
'anyio' not found in `markers` configuration option
____________________________ ERROR collecting tests/streams/test_tls.py ____________________________
'anyio' not found in `markers` configuration option
!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 19 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================== 19 errors in 0.13s ========================================

so here the module is found and pytest complains that anyio is not registered in the config as a marker, now if i add pytest.ini

root@zion:/build/python-anyio-3.3.0# COLUMNS=100 PYTHONPATH=.pybuild/cpython3_3.9/build/  pytest-3 
======================================= test session starts ========================================
platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-0.13.0
rootdir: /build/python-anyio-3.3.0, configfile: pytest.ini
plugins: mock-3.6.1
collected 377 items / 2 errors / 375 selected                                                      

============================================== ERRORS ==============================================
____________________________ ERROR collecting tests/test_taskgroups.py _____________________________
In test_start_native_host_cancelled: function uses no argument 'anyio_backend'
_____________________________ ERROR collecting tests/test_to_thread.py _____________________________
In test_asyncio_cancel_native_task: function uses no argument 'anyio_backend'
===================================== short test summary info ======================================
ERROR tests/test_taskgroups.py
ERROR tests/test_to_thread.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================== 2 errors in 0.33s =========================================

so it seems somehow only when using anyio_backend we have an issue, is there anything special about it?

The way we are building this package is by running /usr/bin/python3 setup.py build with /build/python-anyio-3.3.0/.pybuild/cpython3_3.9/build/ as a dest dir, and then run cd /build/python-anyio-3.3.0/.pybuild/cpython3_3.9/build; python3.9 -m pytest tests to run the tests

@agronholm
Copy link
Owner

agronholm commented Sep 8, 2021

Again, the reason this is happening is because pytest cannot detect the AnyIO pytest plugin. The plugin is not detected via setuptools entrypoints since the project has not been installed. Adding the marker is pointless since the pytest plugin does that on its own which is why it's not present in pyproject.toml.

The python setup.py build copies the code but not the project metadata (.dist-info or .egg-info) which contains entry_points.txt which is crucial for the test suite to run properly since it depends on its own pytest plugin. What you need, at the minimum, is to run python setup.py egg_info and ensure that the directory containing the .egg-info directory is on PYTHONPATH. Installing the project would be easier but if you don't want to do it that way, this is an alternative method.

@sandrotosi
Copy link
Author

OMG yes, you're right, sorry i didnt register before what you meant with entry point. running egg_info helped and now the test suite runs.

sadly there's still several errors (34 failed, 797 passed, 4 skipped, 13 errors), but this may be due to the way we're running out build environment (f.e. no internet access): let me go thru them and will post here if there's some i dont understand and i need help with.

thanks for your help so far!

@agronholm
Copy link
Owner

You can skip the network tests with the pytest switch -p no:network.

@sandrotosi
Copy link
Author

so the network issues are due to the build env thinks it has IPv6 support while it actually does not, so i can easily disable that. What's left is this weird error in the test_pytest_plugin.py:

========================================================================== test session starts ===========================================================================
platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-0.13.0 -- /usr/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/build/python-anyio-3.3.0/.hypothesis/examples')
rootdir: /build/python-anyio-3.3.0, configfile: pyproject.toml
plugins: anyio-3.3.0, hypothesis-5.43.3, mock-3.6.1
collected 6 items                                                                                                                                                        

tests/test_pytest_plugin.py::test_plugin FAILED                                                                                                                    [ 16%]
tests/test_pytest_plugin.py::test_asyncio PASSED                                                                                                                   [ 33%]
tests/test_pytest_plugin.py::test_autouse_async_fixture FAILED                                                                                                     [ 50%]
tests/test_pytest_plugin.py::test_cancel_scope_in_asyncgen_fixture FAILED                                                                                          [ 66%]
tests/test_pytest_plugin.py::test_hypothesis_module_mark FAILED                                                                                                    [ 83%]
tests/test_pytest_plugin.py::test_hypothesis_function_mark FAILED                                                                                                  [100%]

================================================================================ FAILURES ================================================================================
______________________________________________________________________________ test_plugin _______________________________________________________________________________
/build/python-anyio-3.3.0/tests/test_pytest_plugin.py:65: in test_plugin
    result.assert_outcomes(passed=3 * len(get_all_backends()), skipped=len(get_all_backends()))
E   AssertionError: assert {'errors': 21...pped': 0, ...} == {'errors': 0,...pped': 7, ...}
E     Omitting 2 identical items, use -vv to show
E     Differing items:
E     {'failed': 7} != {'failed': 0}
E     {'passed': 0} != {'passed': 21}
E     {'skipped': 0} != {'skipped': 7}
E     {'errors': 21} != {'errors': 0}
E     Full diff:...
E     
E     ...Full output truncated (21 lines hidden), use '-vv' to show
-------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------
========================================================================== test session starts ===========================================================================
platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-0.13.0 -- /usr/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/build/python-anyio-3.3.0/.hypothesis/examples')
rootdir: /tmp/pytest-of-root/pytest-19/test_plugin0
plugins: anyio-3.3.0, hypothesis-5.43.3, mock-3.6.1
collecting ... collected 28 items

test_plugin.py::test_marked_test[a] FAILED                                                                                                                         [  3%]
test_plugin.py::test_marked_test[s] FAILED                                                                                                                         [  7%]
test_plugin.py::test_marked_test[y] FAILED                                                                                                                         [ 10%]
test_plugin.py::test_marked_test[n] FAILED                                                                                                                         [ 14%]
test_plugin.py::test_marked_test[c] FAILED                                                                                                                         [ 17%]
test_plugin.py::test_marked_test[i] FAILED                                                                                                                         [ 21%]
test_plugin.py::test_marked_test[o] FAILED                                                                                                                         [ 25%]
test_plugin.py::test_async_fixture_from_marked_test[a] ERROR                                                                                                       [ 28%]
test_plugin.py::test_async_fixture_from_marked_test[s] ERROR                                                                                                       [ 32%]
test_plugin.py::test_async_fixture_from_marked_test[y] ERROR                                                                                                       [ 35%]
test_plugin.py::test_async_fixture_from_marked_test[n] ERROR                                                                                                       [ 39%]
test_plugin.py::test_async_fixture_from_marked_test[c] ERROR                                                                                                       [ 42%]
test_plugin.py::test_async_fixture_from_marked_test[i] ERROR                                                                                                       [ 46%]
test_plugin.py::test_async_fixture_from_marked_test[o] ERROR                                                                                                       [ 50%]
test_plugin.py::test_async_fixture_from_sync_test[a] ERROR                                                                                                         [ 53%]
test_plugin.py::test_async_fixture_from_sync_test[s] ERROR                                                                                                         [ 57%]
test_plugin.py::test_async_fixture_from_sync_test[y] ERROR                                                                                                         [ 60%]
test_plugin.py::test_async_fixture_from_sync_test[n] ERROR                                                                                                         [ 64%]
test_plugin.py::test_async_fixture_from_sync_test[c] ERROR                                                                                                         [ 67%]
test_plugin.py::test_async_fixture_from_sync_test[i] ERROR                                                                                                         [ 71%]
test_plugin.py::test_async_fixture_from_sync_test[o] ERROR                                                                                                         [ 75%]
test_plugin.py::test_skip_inline[a] ERROR                                                                                                                          [ 78%]
test_plugin.py::test_skip_inline[s] ERROR                                                                                                                          [ 82%]
test_plugin.py::test_skip_inline[y] ERROR                                                                                                                          [ 85%]
test_plugin.py::test_skip_inline[n] ERROR                                                                                                                          [ 89%]
test_plugin.py::test_skip_inline[c] ERROR                                                                                                                          [ 92%]
test_plugin.py::test_skip_inline[i] ERROR                                                                                                                          [ 96%]
test_plugin.py::test_skip_inline[o] ERROR                                                                                                                          [100%]
...
======================================================================== short test summary info =========================================================================
FAILED test_plugin.py::test_marked_test[a] - ModuleNotFoundError: No module named 'anyio._backends._a'
FAILED test_plugin.py::test_marked_test[s] - ModuleNotFoundError: No module named 'anyio._backends._s'
FAILED test_plugin.py::test_marked_test[y] - ModuleNotFoundError: No module named 'anyio._backends._y'
FAILED test_plugin.py::test_marked_test[n] - ModuleNotFoundError: No module named 'anyio._backends._n'
FAILED test_plugin.py::test_marked_test[c] - ModuleNotFoundError: No module named 'anyio._backends._c'
FAILED test_plugin.py::test_marked_test[i] - ModuleNotFoundError: No module named 'anyio._backends._i'
FAILED test_plugin.py::test_marked_test[o] - ModuleNotFoundError: No module named 'anyio._backends._o'
ERROR test_plugin.py::test_async_fixture_from_marked_test[a] - ModuleNotFoundError: No module named 'anyio._backends._a'
ERROR test_plugin.py::test_async_fixture_from_marked_test[s] - ModuleNotFoundError: No module named 'anyio._backends._s'
ERROR test_plugin.py::test_async_fixture_from_marked_test[y] - ModuleNotFoundError: No module named 'anyio._backends._y'
ERROR test_plugin.py::test_async_fixture_from_marked_test[n] - ModuleNotFoundError: No module named 'anyio._backends._n'
ERROR test_plugin.py::test_async_fixture_from_marked_test[c] - ModuleNotFoundError: No module named 'anyio._backends._c'
ERROR test_plugin.py::test_async_fixture_from_marked_test[i] - ModuleNotFoundError: No module named 'anyio._backends._i'
ERROR test_plugin.py::test_async_fixture_from_marked_test[o] - ModuleNotFoundError: No module named 'anyio._backends._o'
ERROR test_plugin.py::test_async_fixture_from_sync_test[a] - ModuleNotFoundError: No module named 'anyio._backends._a'
ERROR test_plugin.py::test_async_fixture_from_sync_test[s] - ModuleNotFoundError: No module named 'anyio._backends._s'
ERROR test_plugin.py::test_async_fixture_from_sync_test[y] - ModuleNotFoundError: No module named 'anyio._backends._y'
ERROR test_plugin.py::test_async_fixture_from_sync_test[n] - ModuleNotFoundError: No module named 'anyio._backends._n'
ERROR test_plugin.py::test_async_fixture_from_sync_test[c] - ModuleNotFoundError: No module named 'anyio._backends._c'
ERROR test_plugin.py::test_async_fixture_from_sync_test[i] - ModuleNotFoundError: No module named 'anyio._backends._i'
ERROR test_plugin.py::test_async_fixture_from_sync_test[o] - ModuleNotFoundError: No module named 'anyio._backends._o'
ERROR test_plugin.py::test_skip_inline[a] - ModuleNotFoundError: No module named 'anyio._backends._a'
ERROR test_plugin.py::test_skip_inline[s] - ModuleNotFoundError: No module named 'anyio._backends._s'
ERROR test_plugin.py::test_skip_inline[y] - ModuleNotFoundError: No module named 'anyio._backends._y'
ERROR test_plugin.py::test_skip_inline[n] - ModuleNotFoundError: No module named 'anyio._backends._n'
ERROR test_plugin.py::test_skip_inline[c] - ModuleNotFoundError: No module named 'anyio._backends._c'
ERROR test_plugin.py::test_skip_inline[i] - ModuleNotFoundError: No module named 'anyio._backends._i'
ERROR test_plugin.py::test_skip_inline[o] - ModuleNotFoundError: No module named 'anyio._backends._o'
====================================================================== 7 failed, 21 errors in 0.40s ======================================================================

(i just reported the first set of tests) it looks like it's expecting a list, gets a string and so iterates on each character of that string; does that look familiar to you?

@agronholm
Copy link
Owner

I have never seen this error before. Can you report what Python gives as output when you do import anyio; print(anyio.get_all_backends())?

@sandrotosi
Copy link
Author

>>> import anyio; print(anyio.get_all_backends())
asyncio

@agronholm
Copy link
Owner

That function returns a hard coded tuple of backend names (here). Have you modified the source in a way that breaks the tests?

@sandrotosi
Copy link
Author

you're right! we disabled the trio backend in https://salsa.debian.org/python-team/packages/python-anyio/-/blob/master/debian/patches/disable_backends.patch#L43 but the implicit tuple was not preserved (as a suggestion, maybe make it an explicit tuple wrapping that in parenthesis?), once i make it a tuple of 1 element, the test passed

i think we're done here and all the problems i was seeing are gone -- thanks again for your help

@sandrotosi
Copy link
Author

too soon :) we got another couple of errors:

____________________________________________________________________________________________________________________ test_task_group_in_generator[asyncio] _____________________________________________________________________________________________________________________
tests/test_taskgroups.py:733: in test_task_group_in_generator
    anyio.run(gen.__anext__, backend=anyio_backend_name,  # type: ignore[arg-type]
anyio/_core/_eventloop.py:56: in run
    return asynclib.run(func, *args, **backend_options)  # type: ignore
anyio/_backends/_asyncio.py:230: in run
    return native_run(wrapper(), debug=debug)
/usr/lib/python3.9/asyncio/runners.py:48: in run
    loop.run_until_complete(loop.shutdown_asyncgens())
/usr/lib/python3.9/asyncio/base_events.py:642: in run_until_complete
    return future.result()
/usr/lib/python3.9/asyncio/base_events.py:542: in shutdown_asyncgens
    results = await tasks.gather(
/usr/lib/python3.9/asyncio/tasks.py:755: in gather
    warnings.warn("The loop argument is deprecated since Python 3.8, "
E   DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
________________________________________________________________________________________________________________________ test_unhandled_exception_group ________________________________________________________________________________________________________________________
/usr/lib/python3.9/asyncio/runners.py:44: in run
    return loop.run_until_complete(main)
uvloop/loop.pyx:1495: in uvloop.loop.Loop.run_until_complete
    ???
uvloop/loop.pyx:1488: in uvloop.loop.Loop.run_until_complete
    ???
uvloop/loop.pyx:1377: in uvloop.loop.Loop.run_forever
    ???
uvloop/loop.pyx:550: in uvloop.loop.Loop._run
    ???
uvloop/loop.pyx:467: in uvloop.loop.Loop._on_idle
    ???
uvloop/cbhandles.pyx:83: in uvloop.loop.Handle._run
    ???
uvloop/cbhandles.pyx:61: in uvloop.loop.Handle._run
    ???
tests/test_taskgroups.py:945: in crash
    raise KeyboardInterrupt
E   KeyboardInterrupt

During handling of the above exception, another exception occurred:
tests/test_taskgroups.py:962: in test_unhandled_exception_group
    anyio.run(main, backend='asyncio')
anyio/_core/_eventloop.py:56: in run
    return asynclib.run(func, *args, **backend_options)  # type: ignore
anyio/_backends/_asyncio.py:230: in run
    return native_run(wrapper(), debug=debug)
/usr/lib/python3.9/asyncio/runners.py:47: in run
    _cancel_all_tasks(loop)
/usr/lib/python3.9/asyncio/runners.py:64: in _cancel_all_tasks
    tasks.gather(*to_cancel, loop=loop, return_exceptions=True))
/usr/lib/python3.9/asyncio/tasks.py:755: in gather
    warnings.warn("The loop argument is deprecated since Python 3.8, "
E   DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.

do you think you can have a look at this too? thanks!

@sandrotosi sandrotosi reopened this Sep 9, 2021
@agronholm
Copy link
Owner

you're right! we disabled the trio backend in https://salsa.debian.org/python-team/packages/python-anyio/-/blob/master/debian/patches/disable_backends.patch#L43 but the implicit tuple was not preserved (as a suggestion, maybe make it an explicit tuple wrapping that in parenthesis?), once i make it a tuple of 1 element, the test passed

This tuple is not a part of the API and thus was not designed to be altered. Furthermore, the return annotation of get_all_backends() specifies that it returns a tuple, so if you patch the source to return something else, that's not on me.

do you think you can have a look at this too? thanks!

What version of uvloop are you running?

@sandrotosi
Copy link
Author

What version of uvloop are you running?

0.16.0

@agronholm
Copy link
Owner

This does not look like it was caused by anyio, as anyio does not pass the loop argument anywhere in the traceback. Can you either find out where the loop argument is coming from, or instruct me to reproduce this error locally?

@agronholm
Copy link
Owner

Also, does this happen without uvloop (-k "not uvloop")?

@agronholm
Copy link
Owner

/usr/lib/python3.9/asyncio/runners.py:64: in _cancel_all_tasks
tasks.gather(*to_cancel, loop=loop, return_exceptions=True))
/usr/lib/python3.9/asyncio/tasks.py:755: in gather
warnings.warn("The loop argument is deprecated since Python 3.8, "
E DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.

This looks like asyncio itself is passing the deprecated loop argument, but it doesn't make sense.

@agronholm
Copy link
Owner

@sandrotosi
Copy link
Author

i think it's pytest that interprets a warning as an error nowdays, setting

pytest-warnings:
  -W PYTHONWARNINGS, --pythonwarnings=PYTHONWARNINGS
                        set which warnings to report, see -W option of python itself.

as -W ignore makes the test suite to complete fine

@agronholm
Copy link
Owner

I was just typing a message saying that relaxing the pytest warning filter would let the test suite pass :)

@agronholm
Copy link
Owner

I am still on Python 3.9.6 myself; you're running 3.9.7 which slightly alters the handling of async generators which may have triggered this error.

@agronholm
Copy link
Owner

Yup, I just installed 3.9.7 from source and I get the same test failures with that version.

@agronholm
Copy link
Owner

@agronholm
Copy link
Owner

I should also point out that you should probably package v3.3.1 which I released a couple days ago.

@sandrotosi
Copy link
Author

I should also point out that you should probably package v3.3.1 which I released a couple days ago.

Another Debian developer took care of that, i think we're all set here -- thanks a lot for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants