Error loading conftest.py due to missing field "lineno" from alias

578 Views Asked by At

I have a python/flask application with a test suite.

When I run

coverage run -m pytest -s tests

I get the following error:

ImportError while loading conftest '/Users/abc/Documents/server/app/tests/conftest.py TypeError: required field "lineno" missing from alias

My python version is 3.10.9 I am using macOS Moneterey 12.5 with Apple M1 Pro Chip. Coverage version is 5.0 with C extension. My pytest version is 7.1.1.

What I tried :

I encountered this problem on Python 3.8.9, and upgraded to 3.10.9. I also upgraded pytest to the latest version.

Then again I ran coverage run -m pytest -s tests

What I expected to happen:

I was expecting that the tests would start running.

What actually resulted:

ImportError while loading conftest '/Users/abc/Documents/server/app/tests/conftest.py TypeError: required field "lineno" missing from alias

1

There are 1 best solutions below

0
On

This error is due to the fact that the installed version of Python does not match the installed version of the pytest, you should check and update your pytest and Python version .

python --version

and for seeing pytest version use :

pip list