Lucretiel / autocommand

Autocommand turns a python function into a CLI program
GNU Lesser General Public License v3.0
52 stars 9 forks source link

2.2.1: pytest is failing and some `PytestDeprecationWarning` warnings #19

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 build, install and test cycle used on building packages from non-root account.

May I ask for help because few units are failing:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-autocommand-2.2.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-autocommand-2.2.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.10.0, pluggy-0.13.1
Using --randomly-seed=3030213684
rootdir: /home/tkloczko/rpmbuild/BUILD/autocommand-2.2.1
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, flake8-1.0.7, xdist-2.3.0, cov-2.12.1, mock-3.6.1, localserver-0.5.0, timeout-2.0.1, flaky-3.7.0, hypothesis-6.14.6, rerunfailures-9.1.1, checkdocs-2.7.1, anyio-3.3.1, tornasync-0.6.0.post2, randomly-3.8.0, freezegun-0.4.2, pylama-7.7.1, black-0.3.12, trio-0.7.0, twisted-1.13.3, asyncio-0.15.1
collected 65 items / 1 error / 64 selected

================================================================================== ERRORS ==================================================================================
_________________________________________________________________ ERROR collecting test/test_autoasync.py __________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/python.py:578: in _importtestmodule
    mod = import_path(self.fspath, mode=importmode)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:524: in import_path
    importlib.import_module(module_name)
/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:161: in exec_module
    source_stat, co = _rewrite_test(fn, self.config)
/usr/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:354: in _rewrite_test
    tree = ast.parse(source, filename=fn_)
/usr/lib64/python3.8/ast.py:47: in parse
    return compile(source, filename, mode, flags,
E     File "/home/tkloczko/rpmbuild/BUILD/autocommand-2.2.1/test/test_autoasync.py", line 84
E       task1 = asyncio.async(coro_1())
E                       ^
E   SyntaxError: invalid syntax
============================================================================= warnings summary =============================================================================
test/test_autocommand.py:45
  /home/tkloczko/rpmbuild/BUILD/autocommand-2.2.1/test/test_autocommand.py:45: PytestDeprecationWarning: @pytest.yield_fixture is deprecated.
  Use @pytest.fixture instead; they are the same.
    def patched_autoparse():

test/test_autocommand.py:54
  /home/tkloczko/rpmbuild/BUILD/autocommand-2.2.1/test/test_autocommand.py:54: PytestDeprecationWarning: @pytest.yield_fixture is deprecated.
  Use @pytest.fixture instead; they are the same.
    def patched_autoasync():

test/test_autocommand.py:66
  /home/tkloczko/rpmbuild/BUILD/autocommand-2.2.1/test/test_autocommand.py:66: PytestDeprecationWarning: @pytest.yield_fixture is deprecated.
  Use @pytest.fixture instead; they are the same.
    def patched_automain():

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
ERROR test/test_autoasync.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================================= 3 warnings, 1 error in 0.38s =======================================================================
Lucretiel commented 2 years ago

Good catch! These are now fixed in master. Will cut a release later this week. Mostly these are all due to out-of-date / incompatible patterns from around python 3.4/3.5

kloczek commented 2 years ago

Just tested that commit and it fixes the issue (thank you :)) I found that latest pytest shows some warning :P

============================================================================= warnings summary =============================================================================
test/test_autoasync.py::test_custom_loop
  /usr/lib64/python3.8/asyncio/base_events.py:641: RuntimeWarning: coroutine 'test_custom_loop.<locals>.bad_coro' was never awaited
    self._ready.clear()

-- Docs: https://docs.pytest.org/en/stable/warnings.html
====================================================================== 72 passed, 1 warning in 0.71s =======================================================================
Lucretiel commented 2 years ago

Yeah I saw that too I think. I'm not actually sure how to resolve right now, since that tests depends on bad_coro not running in the first place