0

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

sage76
  • 1
  • 4
  • That looks unusual. Why are you using coverage 5.0 (from December 2019)? Can you link to your code? Do you have type aliases defined in your conftest.py? – Ned Batchelder Jan 12 '23 at 11:30
  • @NedBatchelder I'm using whatever versions of packages are specified by the codebase of the company. No there are no type aliases in conftest.py – sage76 Apr 30 '23 at 14:11

1 Answers1

0

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

Ophir Carmi
  • 2,701
  • 1
  • 23
  • 42
Fat3mi
  • 11
  • 1