pytest " fixture 'url' not found",而没有使用任何夹具。

问题描述 投票:1回答:1

当我尝试执行测试时(python3 -m pytest dir1/subdir/test.py)我得到了错误信息,但我没有在代码中使用任何 "url "夹具。

__________________________ ERROR at setup of testcase __________________________
file /usr/local/lib/python3.6/site-packages/allure_commons/_allure.py, line 50
  def testcase(url, name=None):
E       fixture 'url' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_xml_property, recwarn, tmpdir, tmpdir_factory, worker_id
>       use 'pytest --fixtures [testpath]' for help on them.

/usr/local/lib/python3.6/site-packages/allure_commons/_allure.py:50
=========================== 1 error in 0.40 seconds ============================

但我没有在代码中使用任何 "url "夹具,我甚至尝试重命名项目中的每个 "url "变量,但问题仍然存在。

安装的需求。

allure-pytest==2.8.16
allure-python-commons==2.8.16
atomicwrites==1.4.0
attrs==19.3.0
axe-selenium-python==2.1.6
certifi==2020.4.5.2
chardet==3.0.4
colorama==0.4.3
configparser==5.0.0
coverage==5.1
crayons==0.3.1
cx-Oracle==7.3.0
Faker==4.1.0
flaky==3.6.1
idna==2.9
importlib-metadata==1.6.1
iso3166==1.0.1
more-itertools==8.3.0
packaging==20.4
page-objects==1.1.0
parameterized==0.7.4
pluggy==0.13.1
py==1.8.1
pycountry==19.8.18
pyparsing==2.4.7
pytest==5.4.3
python-dateutil==2.8.1
PyYAML==5.3.1
requests==2.23.0
schwifty==2020.5.3
selenium==3.141.0
simple-value-object==1.3
six==1.15.0
text-unidecode==1.3
urllib3==1.25.9
wcwidth==0.2.4
webdriver-manager==2.5.3
zipp==3.1.0
python automated-tests pytest allure
1个回答
0
投票

[UPDATE]我终于找到了一个解决方案。原来,我必须添加 __test__ = True 到我的测试类中。

顺便说一下:我所有的测试都是继承自 TestBase(unittest.TestCase) 类,它有属性 __test__ = False. 这个属性的目的是为了不重复执行测试--一次来自基类,第二次来自继承类。更多详情。https:/www.termitnjak.comenblogpytest-inheritance-problems

© www.soinside.com 2019 - 2024. All rights reserved.