【问题标题】:Pytest fixtures in different subfolders are not recognized无法识别不同子文件夹中的 Pytest 固定装置
【发布时间】:2021-03-29 14:23:11
【问题描述】:

如果我有一个包含以下代码结构的仓库:

repo/
-- test
  -- preprocess
     -- conftest.py
     -- test_preprocess.py
  -- classifier
     -- conftest.py
     -- test_classifier.py

如何在test_classifier.py 内部调用test/preprocess/conftest.py 中定义的夹具?我试过这个,我的固定装置没有被识别。谢谢!

【问题讨论】:

    标签: python pytest


    【解决方案1】:
    repo/
    -- test
      -- conftest.py <--- for fixtures shared for all subfolders' tests
      -- preprocess
         -- conftest.py
         -- test_preprocess.py
      -- classifier
         -- conftest.py
         -- test_classifier.py
    

    见Sharing Fixtures Across Files

    【讨论】:

      猜你喜欢
      • 2021-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-06
      • 2018-02-10
      • 1970-01-01
      相关资源
      最近更新 更多