How and where does py.test find fixtures

前端 未结 3 1562
别跟我提以往
别跟我提以往 2020-12-14 15:07

Where and how does py.test look for fixtures? I have the same code in 2 files in the same folder. When I delete conftest.py, cmdopt cannot be found running tes

3条回答
  •  情歌与酒
    2020-12-14 15:35

    Here is the order and where py.test looks for fixtures (and tests) (taken from here):

    py.test loads plugin modules at tool startup in the following way:

    1. by loading all builtin plugins

    2. by loading all plugins registered through setuptools entry points.

    3. by pre-scanning the command line for the -p name option and loading the specified plugin before actual command line parsing.

    4. by loading all conftest.py files as inferred by the command line invocation (test files and all of its parent directories). Note that conftest.py files from sub directories are by default not loaded at tool startup.

    5. by recursively loading all plugins specified by the pytest_plugins variable in conftest.py files

提交回复
热议问题