Lucretiel / autocommand

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

asyncio.async invalid syntax error in test suite #20

Closed Apteryks closed 1 year ago

Apteryks commented 2 years ago

Hello,

Attempting to package this for Guix I encountered the following error:

starting phase `check'
============================= test session starts ==============================
platform linux -- Python 3.9.9, pytest-6.2.5, py-1.10.0, pluggy-0.13.1 -- /gnu/store/j3cx0yaqdpw0mxizp5bayx93pya44dhn-python-wrapper-3.9.9/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/tmp/guix-build-python-autocommand-2.2.1.drv-0/autocommand-2.2.1/.hypothesis/examples')
rootdir: /tmp/guix-build-python-autocommand-2.2.1.drv-0/autocommand-2.2.1
plugins: hypothesis-6.0.2, asyncio-0.17.2
asyncio: mode=legacy
collecting ... collected 10 items / 1 error / 9 selected

==================================== ERRORS ====================================
___________________ ERROR collecting test/test_autoasync.py ____________________
/gnu/store/rj9gyaqi2ijkll5495jgp7kbfqh02167-python-pytest-6.2.5/lib/python3.9/site-packages/_pytest/python.py:578: in _importtestmodule
    mod = import_path(self.fspath, mode=importmode)
/gnu/store/rj9gyaqi2ijkll5495jgp7kbfqh02167-python-pytest-6.2.5/lib/python3.9/site-packages/_pytest/pathlib.py:524: in import_path
    importlib.import_module(module_name)
/gnu/store/b6j1qw1a5rkbfvcy7lc9fm95abbzpa4x-python-3.9.9/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1030: in _gcd_import
    ???
<frozen importlib._bootstrap>:1007: in _find_and_load
    ???
<frozen importlib._bootstrap>:986: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:680: in _load_unlocked
    ???
/gnu/store/rj9gyaqi2ijkll5495jgp7kbfqh02167-python-pytest-6.2.5/lib/python3.9/site-packages/_pytest/assertion/rewrite.py:161: in exec_module
    source_stat, co = _rewrite_test(fn, self.config)
/gnu/store/rj9gyaqi2ijkll5495jgp7kbfqh02167-python-pytest-6.2.5/lib/python3.9/site-packages/_pytest/assertion/rewrite.py:354: in _rewrite_test
    tree = ast.parse(source, filename=fn_)
/gnu/store/b6j1qw1a5rkbfvcy7lc9fm95abbzpa4x-python-3.9.9/lib/python3.9/ast.py:50: in parse
    return compile(source, filename, mode, flags,
E     File "/tmp/guix-build-python-autocommand-2.2.1.drv-0/autocommand-2.2.1/test/test_autoasync.py", line 84
E       task1 = asyncio.async(coro_1())
E                       ^
E   SyntaxError: invalid syntax
=============================== warnings summary ===============================
../../../gnu/store/0q70jn8vcyvs40z0bcll80zj3aacsw0x-python-pytest-asyncio-0.17.2/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191
  /gnu/store/0q70jn8vcyvs40z0bcll80zj3aacsw0x-python-pytest-asyncio-0.17.2/lib/python3.9/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)

test/test_autocommand.py:45
  /tmp/guix-build-python-autocommand-2.2.1.drv-0/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
  /tmp/guix-build-python-autocommand-2.2.1.drv-0/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
  /tmp/guix-build-python-autocommand-2.2.1.drv-0/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 !!!!!!!!!!!!!!!!!!!!
========================= 4 warnings, 1 error in 0.49s =========================
error: in phase 'check': uncaught exception:
%exception #<&invoke-error program: "pytest" arguments: ("-vv") exit-status: 2 term-signal: #f stop-signal: #f> 
phase `check' failed after 1.5 seconds

Any idea?

Lucretiel commented 2 years ago

Thanks for the report. Yeah, this issue appears because the library was written for earlier versions of python 3, before async was a keyword. Should be a straightforward fix; I don't know when I'll have time to get to it.

felixonmars commented 2 years ago

Looks like it's already fixed in 031c9750c74e3313b954b09e3027aaa6595649bb. A new release would help us packaging it :)

jaraco commented 1 year ago

This issue is also affecting me.

Lucretiel commented 1 year ago

Published 2.2.2, with the resolution