falconry / falcon

The no-magic web data plane API and microservices framework for Python developers, with a focus on reliability, correctness, and performance at scale.
https://falcon.readthedocs.io/en/stable/
Apache License 2.0
9.51k stars 937 forks source link

3.0.1: pytest is failing #2006

Closed kloczek closed 2 years ago

kloczek commented 2 years ago

I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

Lookks like something is wrong in use of aioredis Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-falcon-3.0.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-falcon-3.0.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/falcon-3.0.1, configfile: setup.cfg
plugins: cov-3.0.0, flake8-1.0.7, anyio-3.3.4, asyncio-0.17.2
asyncio: mode=legacy
collected 0 items / 1 error

================================================================================== ERRORS ==================================================================================
______________________________________________________________________ ERROR collecting test session _______________________________________________________________________
/usr/lib64/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
    ???
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:671: in _load_unlocked
    ???
/usr/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:170: in exec_module
    exec(co, module.__dict__)
examples/asgilook/tests/conftest.py:12: in <module>
    from asgilook.app import create_app
examples/asgilook/asgilook/app.py:4: in <module>
    from .config import Config
examples/asgilook/asgilook/config.py:8: in <module>
    class Config:
examples/asgilook/asgilook/config.py:12: in Config
    DEFAULT_REDIS_POOL = aioredis.create_redis_pool
E   AttributeError: module 'aioredis' has no attribute 'create_redis_pool'
============================================================================= warnings summary =============================================================================
../../../../../usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:191
  /usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
    config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
ERROR  - AttributeError: module 'aioredis' has no attribute 'create_redis_pool'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================================= 1 warning, 1 error in 0.72s ========================================================================
kloczek commented 2 years ago

Forgot to add that I'm using aioredis 2.0.1.

vytas7 commented 2 years ago

Hi @kloczek! It is up to you, but it is IMHO quite unusual for packaging tests to include asgilook, E2E or similar. From what I've seen in Falcon's packaging for Debian, Fedora/RedHat, Gentoo, etc, people just exercise the main test suite (i.e. the tests/ directory).

That being said, it is not possible to resolve your issue for 3.0.1 without releasing a new minor or micro version, because aioredis was released after 3.0.1, so we had no clue they would change the interface so radically. The issue (https://github.com/falconry/falcon/issues/1938) is resolved in our master branch via https://github.com/falconry/falcon/pull/1987. As such, we simply can not do anything meaningful here; closing this as duplicate.

(We are hoping to get 3.1.0 out the door some time in February.)

vytas7 commented 2 years ago

Duplicates https://github.com/falconry/falcon/issues/1938

kloczek commented 2 years ago

Just back to falcon trying to finish package 3.1.0. Looks like I need asgilook and there is no that module on pypi.

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-falcon-3.1.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-falcon-3.1.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra --import-mode=importlib
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/falcon-3.1.0, configfile: setup.cfg
collected 0 items / 1 error

================================================================================== ERRORS ==================================================================================
______________________________________________________________________ ERROR collecting test session _______________________________________________________________________
examples/asgilook/tests/conftest.py:12: in <module>
    from asgilook.app import create_app
E   ModuleNotFoundError: No module named 'asgilook'
========================================================================= short test summary info ==========================================================================
ERROR  - ModuleNotFoundError: No module named 'asgilook'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================= 1 error in 0.50s =============================================================================

Any hints?

kloczek commented 2 years ago

It is up to you, but it is IMHO quite unusual for packaging tests to include asgilook, E2E or similar. From what I've seen in Falcon's packaging for Debian, Fedora/RedHat, Gentoo, etc, people just exercise the main test suite (i.e. the tests/ directory).

If only tests/ should be used this patch should be added as testpaths in pytest.ini or pyporoject.toml.

vytas7 commented 2 years ago

This issue has been resolved in Falcon 3.1.0 regardless of what should be included in the test suite. We are not bugfixing SemVer minor versions, please upgrade to 3.1.0.

kloczek commented 2 years ago

This issue has been resolved in Falcon 3.1.0 regardless of what should be included in the test suite.

3.1.0 still has missing testpaths setings.

vytas7 commented 2 years ago

Thanks, but it sounds like an orthogonal suggestion. asgilook tests are now expected to succeed should you decide to include them.

kloczek commented 2 years ago

I wpould like to not stamp on sometbing wgich is still not working like I've reported that in https://github.com/falconry/falcon/issues/2006#issuecomment-1167098538 (which is about last 3.1.0). Just please make a decision about ise more than tests/ at the time when it will be ready.

vytas7 commented 2 years ago

I'll file testpaths as a separate suggestion, thanks. Re the current test (in fact, these are supplement material to one of our tutorials) at hand, I beg to differ on whether this is an issue. We do not necessarily support all our tests being able to run in isolation, we use tox.

Please invoke as tox -e asgilook.

kloczek commented 2 years ago

Please invoke as tox -e asgilook.

"Nobody expects the Spanish Inquisition" .. If that part of examples why not just use examples.asgilook in import lines? 🤔

vytas7 commented 2 years ago

Because the tutorial is written from the reader's perspective building a new project using Falcon, outside of Falcon's source tree.

I'm still not convinced why pytest should work without parameters. Is that defined somewhere in our setup configuration that this is the way how to test the Falcon package?

Why use tox for testing, not pytest. If you invoke pytest in a different way, you're on your own.

CaselIT commented 2 years ago

I think adding testpaths to the pytest setup.cfg file will solve most problems wrt pytest invocation without parameters

vytas7 commented 2 years ago

Yes, I'll file that as a separate suggestion.

@CaselIT it is unclear whether that would help, because I saw in another issue by the same reporter that setup.cfg was not used at all.

CaselIT commented 2 years ago

Unless that's removed by hand that seems very strange that pytest is not picking it up. Regardless adding that should not make things any worse

vytas7 commented 2 years ago

Filed as https://github.com/falconry/falcon/issues/2082