[英]pytest plugins override each other
我寫了 2 個類似的插件:
import pytest
@pytest.fixture
def pyplug<ID>_fixture():
pass
其中<ID>
替換為我給插件的編號,即“0”、“1”...
我為每個插件創建了一個 setup.py:
from setuptools import setup
setup(
name='pyplug<ID>',
packages=['pyplug<ID>'],
entry_points={'pytest11': ['pkg = pyplug<ID>.plugin']}
)
在每個 package 中,我用 plugin.py 文件創建了另一個目錄(同名),其中包含前面描述的夾具。
這是我為每個插件運行python setup.py bdist_wheel
后的目錄樹:
src/
├── pyplug0
│ ├── build
│ │ ├── bdist.linux-x86_64
│ │ └── lib
│ │ └── pyplug0
│ │ └── plugin.py
│ ├── dist
│ │ └── pyplug0-0.0.0-py3-none-any.whl
│ ├── pyplug0
│ │ └── plugin.py
│ ├── pyplug0.egg-info
│ │ ├── dependency_links.txt
│ │ ├── entry_points.txt
│ │ ├── PKG-INFO
│ │ ├── SOURCES.txt
│ │ └── top_level.txt
│ └── setup.py
└── pyplug1
├── build
│ ├── bdist.linux-x86_64
│ └── lib
│ └── pyplug1
│ └── plugin.py
├── dist
│ └── pyplug1-0.0.0-py3-none-any.whl
├── pyplug1
│ └── plugin.py
├── pyplug1.egg-info
│ ├── dependency_links.txt
│ ├── entry_points.txt
│ ├── PKG-INFO
│ ├── SOURCES.txt
│ └── top_level.txt
└── setup.py
這是我的 pip 凍結:
attrs==19.3.0
importlib-metadata==1.6.0
more-itertools==8.2.0
packaging==20.3
pluggy==0.13.1
py==1.8.1
pyparsing==2.4.7
pyplug0==0.0.0
pyplug1==0.0.0
pytest==5.4.1
pytest-html==2.1.1
pytest-metadata==1.8.0
pytest-tldr==0.2.1
six==1.14.0
wcwidth==0.1.9
zipp==3.1.0
這是我的測試文件內容:
def test_plugin(pyplug0_fixture):
pass
def test_plugin2(pyplug1_fixture):
pass
問題是,插件沒有注冊好。 當我只安裝一個(哪個無關緊要)並測試它時,沒問題。 當我安裝兩者時,一個被另一個覆蓋,這在 IMO 中沒有意義,因為它們有不同的名稱(對於夾具和插件)
我在 Ubuntu16.04 上運行 py3.6.10
找到了。 兩個 setup.py 都有相同的入口點:
entry_points={"pytest11": ["KEY = VAL"]}
VAL 不同,但我一直使用相同的 KEY,所以最新的總是贏
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.