Lucretiel / autocommand

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

warning: bad_coro was never awaited #23

Closed jaraco closed 1 year ago

jaraco commented 1 year ago

When running the tests on Python 3.11, I see a warning:

 autocommand master $ git-id
9d95de8
 autocommand master $ pip-run -q . -r test_requirements.txt -- -m pytest
================================================================= test session starts ==================================================================
platform darwin -- Python 3.11.0, pytest-7.2.0, pluggy-1.0.0
rootdir: /Users/jaraco/code/Lucretiel/autocommand
plugins: cov-4.0.0
collected 72 items                                                                                                                                     

test/test_autoasync.py ........                                                                                                                  [ 11%]
test/test_autocommand.py ....                                                                                                                    [ 16%]
test/test_automain.py ......                                                                                                                     [ 25%]
test/test_autoparse/test_annotations.py ...........                                                                                              [ 40%]
test/test_autoparse/test_bad_signature.py ..                                                                                                     [ 43%]
test/test_autoparse/test_basic_autoparse.py ..........                                                                                           [ 56%]
test/test_autoparse/test_invocation.py .......                                                                                                   [ 66%]
test/test_autoparse/test_single_flags.py .........                                                                                               [ 79%]
test/test_autoparse/test_smart_open.py .....                                                                                                     [ 86%]
test/test_autoparse/test_types.py ..........                                                                                                     [100%]

=================================================================== warnings summary ===================================================================
test/test_autoasync.py::test_custom_loop
  /opt/homebrew/Cellar/python@3.11/3.11.0/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py:675: RuntimeWarning: coroutine 'test_custom_loop.<locals>.bad_coro' was never awaited
    self._ready.clear()
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================ 72 passed, 1 warning in 0.50s =============================================================

If that warning is intentional, it should be suppressed.

Lucretiel commented 1 year ago

It's a known issue that I actually don't know how to fix; happy to accept pull requests or ideas.

https://github.com/Lucretiel/autocommand/blob/9d95de8ad227a76604a9205b5b211bc2a0576e91/test/test_autoasync.py#L110-L112

It is intentional that the task is never awaited; that's the point of the test. In practice you're not really supposed to drop tasks, hence the warning.