PATH issue with pytest 'ImportError: No module named YadaYadaYada'

前端 未结 20 2396
孤独总比滥情好
孤独总比滥情好 2020-11-22 07:10

I used easy_install to install pytest on a mac and started writing tests for a project with a file structure likes so:

repo/
repo/app.py
repo/settings.py
rep         


        
20条回答
  •  鱼传尺愫
    2020-11-22 07:40

    I'm not sure why py.test does not add the current directory in the PYTHONPATH itself, but here's a workaround (to be executed from the root of your repository):

    python -m pytest tests/
    

    It works because Python adds the current directory in the PYTHONPATH for you.

提交回复
热议问题