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

Pytest crash when executing in WSL2 #11083

Closed
4 tasks
Niorlys opened this issue Jun 5, 2023 · 3 comments
Closed
4 tasks

Pytest crash when executing in WSL2 #11083

Niorlys opened this issue Jun 5, 2023 · 3 comments

Comments

@Niorlys
Copy link

Niorlys commented Jun 5, 2023

Error:
(venv) niorlys@NIORLYS:~/study/fastapi-all_the_way/items_manager/tests$ pytest test_items.py
======================================================================== test session starts ========================================================================
platform linux -- Python 3.8.10, pytest-7.2.0, pluggy-1.0.0
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/_pytest/main.py", line 268, in wrap_session
INTERNALERROR> config.hook.pytest_sessionstart(session=session)
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pluggy/_hooks.py", line 265, in call
INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/_pytest/terminal.py", line 720, in pytest_sessionstart
INTERNALERROR> lines = self.config.hook.pytest_report_header(
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/_pytest/config/compat.py", line 67, in fixed_hook
INTERNALERROR> return hook(**kw)
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pluggy/_hooks.py", line 265, in call
INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pytest_asyncio/plugin.py", line 183, in pytest_report_header
INTERNALERROR> mode = _get_asyncio_mode(config)
INTERNALERROR> File "/home/niorlys/study/fastapi-all_the_way/venv/lib/python3.8/site-packages/pytest_asyncio/plugin.py", line 167, in _get_asyncio_mode
INTERNALERROR> return Mode(val)
INTERNALERROR> File "/usr/lib/python3.8/enum.py", line 339, in call
INTERNALERROR> return cls.new(cls, value)
INTERNALERROR> File "/usr/lib/python3.8/enum.py", line 663, in new
INTERNALERROR> raise ve_exc
INTERNALERROR> ValueError: 'True' is not a valid Mode

  • Description: Invoking pytest results in a crash INTERALERROR
  • pip list:
    Package Version

anyio 3.6.2
async-timeout 4.0.2
attrs 23.1.0
bcrypt 4.0.1
certifi 2023.5.7
click 8.1.3
dnspython 2.3.0
email-validator 2.0.0.post2
exceptiongroup 1.1.1
fastapi 0.95.1
h11 0.14.0
httpcore 0.17.2
httpx 0.24.1
idna 3.4
iniconfig 2.0.0
jose 1.0.0
packaging 23.1
passlib 1.7.4
pip 20.0.2
pkg-resources 0.0.0
pluggy 1.0.0
pydantic 1.10.7
PyJWT 2.7.0
pytest 7.2.0
pytest-asyncio 0.21.0
python-multipart 0.0.6
redis 4.5.5
setuptools 44.0.0
sniffio 1.3.0
starlette 0.26.1
tomli 2.0.1
typing-extensions 4.5.0
ujson 5.7.0
uvicorn 0.22.0

@The-Compiler
Copy link
Member

According to the stacktrace, this is coming from pytest-asyncio - most likely because you set asyncio_mode to an incorrect value. Not a pytest issue in either case.

@The-Compiler The-Compiler closed this as not planned Won't fix, can't repro, duplicate, stale Jun 5, 2023
The-Compiler added a commit to The-Compiler/pytest-asyncio that referenced this issue Jun 6, 2023
Instead of a long INTERNALERROR> stack trace, output a proper error
message:

    $ pytest -o asyncio_mode=True
    =================== test session starts ====================
    platform linux -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
    ERROR: 'True' is not a valid asyncio_mode

See pytest-dev/pytest#11083
@The-Compiler
Copy link
Member

I opened a PR against pytest-asyncio to improve the error message: pytest-dev/pytest-asyncio#557

The-Compiler added a commit to The-Compiler/pytest-asyncio that referenced this issue Jun 6, 2023
Instead of a long INTERNALERROR> stack trace, output a proper error
message:

    $ pytest -o asyncio_mode=True
    =================== test session starts ====================
    platform linux -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
    ERROR: 'True' is not a valid asyncio_mode. Valid modes: auto, strict.

See pytest-dev/pytest#11083
The-Compiler added a commit to The-Compiler/pytest-asyncio that referenced this issue Jun 6, 2023
Instead of a long INTERNALERROR> stack trace, output a proper error
message:

    $ pytest -o asyncio_mode=True
    =================== test session starts ====================
    platform linux -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
    ERROR: 'True' is not a valid asyncio_mode. Valid modes: auto, strict.

See pytest-dev/pytest#11083
seifertm pushed a commit to pytest-dev/pytest-asyncio that referenced this issue Jun 7, 2023
Instead of a long INTERNALERROR> stack trace, output a proper error
message:

    $ pytest -o asyncio_mode=True
    =================== test session starts ====================
    platform linux -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
    ERROR: 'True' is not a valid asyncio_mode. Valid modes: auto, strict.

See pytest-dev/pytest#11083
@The-Compiler
Copy link
Member

The PR got merged, so with the next pytest-asyncio release, this will now print:

$ pytest -o asyncio_mode=True
=================== test session starts ====================
platform linux -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
ERROR: 'True' is not a valid asyncio_mode. Valid modes: auto, strict.

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