How to I organize my pytest tests if I'm not distributing them with my package?

前端 未结 1 1239
醉梦人生
醉梦人生 2021-01-20 13:22

As suggested in the pytest documentation, I have set up my package with the intent not not distributing my tests along with my package:

setup.py
myp         


        
1条回答
  •  礼貌的吻别
    2021-01-20 13:34

    The problem is just that python can't find your appmodule when you ask for it to look in the mypkg directory where it doesn't exist.

    You've set the directories up correctly with:

    setup.py
    mypkg/
        __init__.py
        mypkg/
            appmodule.py  
    tests/
        test_app.py
        ...
    

    But since you've created another mypkg/ subdirectory to house your appmodule.py, you'll need to place __init__.py in that subdirectory for an import to work. The call would also be changed to:

    from mypkg.mypkg.appmodule import *
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题