py.test: error: unrecognized arguments: --cov=ner_brands --cov-report=term-missing --cov-config

后端 未结 6 2250
囚心锁ツ
囚心锁ツ 2021-02-06 20:20

when I am trying to run my test through command line

py.test  file_name.py

I got this error:

py.test: error: unrecognized argum         


        
6条回答
  •  Happy的楠姐
    2021-02-06 20:35

    On my Ubuntu, I had also similar issue which was caused by having wrong binary for pytest:

    py.test --version
    This is pytest version 4.6.11, imported from /home/myhome/.local/lib/python2.7/site-packages/pytest.pyc
    

    But my current python setup (python --version) was 3.7.7.. I had to run this instead:

    python -m pytest --version
    pytest 6.2.1
    

    Similarly you can run python -m pytest file_name.py or for coverage python -m pytest --cov=my_project tests/.

    I always recommend to check this especially when there are any issues and I think it's a good practice to run this with -m instead of using pytest directly as it may easily happen it points to different version than the one that should be used within your current python environment. (See similar explanation here.)

提交回复
热议问题