packtpublishing / crafting-test-driven-software-with-python Goto Github PK
View Code? Open in Web Editor NEWCrafting Test-Driven Software with Python, published by Packt
License: MIT License
Crafting Test-Driven Software with Python, published by Packt
License: MIT License
Hi I have a trouble with the Testing documentation section. When I use make html
this error occurs: make: *** No rule to make target 'html'. Stop.
I use make through chocolatey. TY
Here is the error captured from terminal
pytest -v
================================================= test session starts ==================================================
platform win32 -- Python 3.9.5, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- C:\bin\python\python-3.9.5\python.exe
cachedir: .pytest_cache
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: C:\Working\gitea\Learn_Python_TDD_packt\Crafting-Test-Driven-Software-with-Python\Source_Code\Chapter07
plugins: anyio-3.3.0, dash-1.21.0, flaky-3.7.0, bdd-5.0.0, benchmark-3.4.1, cov-3.0.0, forked-1.4.0, testmon-1.2.2, xdist-2.5.0
collected 23 items
tests/functional/test_acceptance.py::TestAddingEntries::test_basic PASSED [ 4%]
tests/functional/test_acceptance.py::TestAddingEntries::test_surnames PASSED [ 8%]
tests/functional/test_acceptance.py::TestAddingEntries::test_international_numbers PASSED [ 13%]
tests/functional/test_acceptance.py::TestAddingEntries::test_invalid_strings PASSED [ 17%]
tests/functional/test_acceptance.py::TestAddingEntries::test_reload PASSED [ 21%]
tests/functional/test_acceptance.py::test_deleting_contacts PASSED [ 26%]
tests/functional/test_acceptance.py::test_listing_added_contacts[Mario-Luigi-Mario,Luigi] FAILED [ 30%]
tests/functional/test_acceptance.py::test_listing_added_contacts[John-Jane-John,Jane] FAILED [ 34%]
tests/unit/test_adding.py::TestAddContacts::test_basic PASSED [ 39%]
tests/unit/test_adding.py::TestAddContacts::test_special PASSED [ 43%]
tests/unit/test_adding.py::TestAddContacts::test_international PASSED [ 47%]
tests/unit/test_adding.py::TestAddContacts::test_invalid PASSED [ 52%]
tests/unit/test_adding.py::TestAddContacts::test_short PASSED [ 56%]
tests/unit/test_adding.py::TestAddContacts::test_missing PASSED [ 60%]
tests/unit/test_application.py::test_application PASSED [ 65%]
tests/unit/test_application.py::test_clear PASSED [ 69%]
tests/unit/test_application.py::TestRun::test_add PASSED [ 73%]
tests/unit/test_application.py::TestRun::test_add_surname PASSED [ 78%]
tests/unit/test_application.py::TestRun::test_empty PASSED [ 82%]
tests/unit/test_application.py::TestRun::test_nocmd PASSED [ 86%]
tests/unit/test_application.py::TestRun::test_invalid PASSED [ 91%]
tests/unit/test_persistence.py::TestLoading::test_load PASSED [ 95%]
tests/unit/test_persistence.py::TestSaving::test_save PASSED [100%]
======================================================= FAILURES =======================================================
_________________________________ test_listing_added_contacts[Mario-Luigi-Mario,Luigi] _________________________________
self = <FixtureRequest for <Function test_listing_added_contacts[Mario-Luigi-Mario,Luigi]>>
argname = 'pytestbdd_given_I have a first Mario contact'
def _get_active_fixturedef(
self, argname: str
) -> Union["FixtureDef[object]", PseudoFixtureDef[object]]:
try:
return self._fixture_defs[argname]
E KeyError: 'pytestbdd_given_I have a first Mario contact'
C:\bin\python\python-3.9.5\lib\site-packages_pytest\fixtures.py:589: KeyError
During handling of the above exception, another exception occurred:
request = <FixtureRequest for <Function test_listing_added_contacts[Mario-Luigi-Mario,Luigi]>>
step = <pytest_bdd.parser.Step object at 0x0000022458CF3670>
scenario = <pytest_bdd.parser.Scenario object at 0x0000022458CF3100>
def _find_step_function(request, step, scenario):
"""Match the step defined by the regular expression pattern.
:param request: PyTest request object.
:param step: Step.
:param scenario: Scenario.
:return: Function of the step.
:rtype: function
"""
name = step.name
try:
# Simple case where no parser is used for the step
return request.getfixturevalue(get_step_fixture_name(name, step.type))
C:\bin\python\python-3.9.5\lib\site-packages\pytest_bdd\scenario.py:77:
self = <FixtureRequest for <Function test_listing_added_contacts[Mario-Luigi-Mario,Luigi]>>
argname = 'pytestbdd_given_I have a first Mario contact'
def getfixturevalue(self, argname: str) -> Any:
"""Dynamically run a named fixture function.
Declaring fixtures via function argument is recommended where possible.
But if you can only decide whether to use another fixture at test
setup time, you may use this function to retrieve it inside a fixture
or test function body.
:raises pytest.FixtureLookupError:
If the given fixture could not be found.
"""
fixturedef = self._get_active_fixturedef(argname)
C:\bin\python\python-3.9.5\lib\site-packages_pytest\fixtures.py:581:
self = <FixtureRequest for <Function test_listing_added_contacts[Mario-Luigi-Mario,Luigi]>>
argname = 'pytestbdd_given_I have a first Mario contact'
def _get_active_fixturedef(
self, argname: str
) -> Union["FixtureDef[object]", PseudoFixtureDef[object]]:
try:
return self._fixture_defs[argname]
except KeyError:
try:
fixturedef = self._getnextfixturedef(argname)
C:\bin\python\python-3.9.5\lib\site-packages_pytest\fixtures.py:592:
self = <FixtureRequest for <Function test_listing_added_contacts[Mario-Luigi-Mario,Luigi]>>
argname = 'pytestbdd_given_I have a first Mario contact'
def _getnextfixturedef(self, argname: str) -> "FixtureDef[Any]":
fixturedefs = self._arg2fixturedefs.get(argname, None)
if fixturedefs is None:
# We arrive here because of a dynamic call to
# getfixturevalue(argname) usage which was naturally
# not known at parsing/collection time.
assert self._pyfuncitem.parent is not None
parentid = self._pyfuncitem.parent.nodeid
fixturedefs = self._fixturemanager.getfixturedefs(argname, parentid)
# TODO: Fix this type ignore. Either add assert or adjust types.
# Can this be None here?
self._arg2fixturedefs[argname] = fixturedefs # type: ignore[assignment]
# fixturedefs list is immutable so we maintain a decreasing index.
index = self._arg2index.get(argname, 0) - 1
if fixturedefs is None or (-index > len(fixturedefs)):
raise FixtureLookupError(argname, self)
E _pytest.fixtures.FixtureLookupError: ('pytestbdd_given_I have a first Mario contact', <FixtureRequest for <Function test_listing_added_contacts[Mario-Luigi-Mario,Luigi]>>)
C:\bin\python\python-3.9.5\lib\site-packages_pytest\fixtures.py:473: FixtureLookupError
During handling of the above exception, another exception occurred:
request = <FixtureRequest for <Function test_listing_added_contacts[Mario-Luigi-Mario,Luigi]>>
_pytest_bdd_example = {'first': 'Mario', 'listed_contacts': 'Mario,Luigi', 'second': 'Luigi'}
@pytest.mark.usefixtures(*args)
def scenario_wrapper(request, _pytest_bdd_example):
scenario = templated_scenario.render(_pytest_bdd_example)
_execute_scenario(feature, scenario, request)
C:\bin\python\python-3.9.5\lib\site-packages\pytest_bdd\scenario.py:174:
C:\bin\python\python-3.9.5\lib\site-packages\pytest_bdd\scenario.py:138: in _execute_scenario
step_func = _find_step_function(request, step, scenario)
request = <FixtureRequest for <Function test_listing_added_contacts[Mario-Luigi-Mario,Luigi]>>
step = <pytest_bdd.parser.Step object at 0x0000022458CF3670>
scenario = <pytest_bdd.parser.Scenario object at 0x0000022458CF3100>
def _find_step_function(request, step, scenario):
"""Match the step defined by the regular expression pattern.
:param request: PyTest request object.
:param step: Step.
:param scenario: Scenario.
:return: Function of the step.
:rtype: function
"""
name = step.name
try:
# Simple case where no parser is used for the step
return request.getfixturevalue(get_step_fixture_name(name, step.type))
except FixtureLookupError:
try:
# Could not find a fixture with the same name, let's see if there is a parser involved
name = find_argumented_step_fixture_name(name, step.type, request._fixturemanager, request)
if name:
return request.getfixturevalue(name)
raise
except FixtureLookupError:
raise exceptions.StepDefinitionNotFoundError(
f"Step definition is not found: {step}. "
f'Line {step.line_number} in scenario "{scenario.name}" in the feature "{scenario.feature.filename}"' )
E pytest_bdd.exceptions.StepDefinitionNotFoundError: Step definition is not found: Given "I have a first Mario contact". Line 6 in scenario "Listing Added Contacts" in the feature "C:\Working\gitea\Learn_Python_TDD_packt\Crafting-Test-Driven-Software-with-Python\Source_Code\Chapter07\tests\acceptance\list_contacts.feature"
C:\bin\python\python-3.9.5\lib\site-packages\pytest_bdd\scenario.py:86: StepDefinitionNotFoundError
___________________________________ test_listing_added_contacts[John-Jane-John,Jane] ___________________________________
self = <FixtureRequest for <Function test_listing_added_contacts[John-Jane-John,Jane]>>
argname = 'pytestbdd_given_I have a first John contact'
def _get_active_fixturedef(
self, argname: str
) -> Union["FixtureDef[object]", PseudoFixtureDef[object]]:
try:
return self._fixture_defs[argname]
E KeyError: 'pytestbdd_given_I have a first John contact'
C:\bin\python\python-3.9.5\lib\site-packages_pytest\fixtures.py:589: KeyError
During handling of the above exception, another exception occurred:
request = <FixtureRequest for <Function test_listing_added_contacts[John-Jane-John,Jane]>>
step = <pytest_bdd.parser.Step object at 0x0000022458CF38E0>
scenario = <pytest_bdd.parser.Scenario object at 0x0000022458CF3940>
def _find_step_function(request, step, scenario):
"""Match the step defined by the regular expression pattern.
:param request: PyTest request object.
:param step: Step.
:param scenario: Scenario.
:return: Function of the step.
:rtype: function
"""
name = step.name
try:
# Simple case where no parser is used for the step
return request.getfixturevalue(get_step_fixture_name(name, step.type))
C:\bin\python\python-3.9.5\lib\site-packages\pytest_bdd\scenario.py:77:
self = <FixtureRequest for <Function test_listing_added_contacts[John-Jane-John,Jane]>>
argname = 'pytestbdd_given_I have a first John contact'
def getfixturevalue(self, argname: str) -> Any:
"""Dynamically run a named fixture function.
Declaring fixtures via function argument is recommended where possible.
But if you can only decide whether to use another fixture at test
setup time, you may use this function to retrieve it inside a fixture
or test function body.
:raises pytest.FixtureLookupError:
If the given fixture could not be found.
"""
fixturedef = self._get_active_fixturedef(argname)
C:\bin\python\python-3.9.5\lib\site-packages_pytest\fixtures.py:581:
self = <FixtureRequest for <Function test_listing_added_contacts[John-Jane-John,Jane]>>
argname = 'pytestbdd_given_I have a first John contact'
def _get_active_fixturedef(
self, argname: str
) -> Union["FixtureDef[object]", PseudoFixtureDef[object]]:
try:
return self._fixture_defs[argname]
except KeyError:
try:
fixturedef = self._getnextfixturedef(argname)
C:\bin\python\python-3.9.5\lib\site-packages_pytest\fixtures.py:592:
self = <FixtureRequest for <Function test_listing_added_contacts[John-Jane-John,Jane]>>
argname = 'pytestbdd_given_I have a first John contact'
def _getnextfixturedef(self, argname: str) -> "FixtureDef[Any]":
fixturedefs = self._arg2fixturedefs.get(argname, None)
if fixturedefs is None:
# We arrive here because of a dynamic call to
# getfixturevalue(argname) usage which was naturally
# not known at parsing/collection time.
assert self._pyfuncitem.parent is not None
parentid = self._pyfuncitem.parent.nodeid
fixturedefs = self._fixturemanager.getfixturedefs(argname, parentid)
# TODO: Fix this type ignore. Either add assert or adjust types.
# Can this be None here?
self._arg2fixturedefs[argname] = fixturedefs # type: ignore[assignment]
# fixturedefs list is immutable so we maintain a decreasing index.
index = self._arg2index.get(argname, 0) - 1
if fixturedefs is None or (-index > len(fixturedefs)):
raise FixtureLookupError(argname, self)
E _pytest.fixtures.FixtureLookupError: ('pytestbdd_given_I have a first John contact', <FixtureRequest for <Function test_listing_added_contacts[John-Jane-John,Jane]>>)
C:\bin\python\python-3.9.5\lib\site-packages_pytest\fixtures.py:473: FixtureLookupError
During handling of the above exception, another exception occurred:
request = <FixtureRequest for <Function test_listing_added_contacts[John-Jane-John,Jane]>>
_pytest_bdd_example = {'first': 'John', 'listed_contacts': 'John,Jane', 'second': 'Jane'}
@pytest.mark.usefixtures(*args)
def scenario_wrapper(request, _pytest_bdd_example):
scenario = templated_scenario.render(_pytest_bdd_example)
_execute_scenario(feature, scenario, request)
C:\bin\python\python-3.9.5\lib\site-packages\pytest_bdd\scenario.py:174:
C:\bin\python\python-3.9.5\lib\site-packages\pytest_bdd\scenario.py:138: in _execute_scenario
step_func = _find_step_function(request, step, scenario)
request = <FixtureRequest for <Function test_listing_added_contacts[John-Jane-John,Jane]>>
step = <pytest_bdd.parser.Step object at 0x0000022458CF38E0>
scenario = <pytest_bdd.parser.Scenario object at 0x0000022458CF3940>
def _find_step_function(request, step, scenario):
"""Match the step defined by the regular expression pattern.
:param request: PyTest request object.
:param step: Step.
:param scenario: Scenario.
:return: Function of the step.
:rtype: function
"""
name = step.name
try:
# Simple case where no parser is used for the step
return request.getfixturevalue(get_step_fixture_name(name, step.type))
except FixtureLookupError:
try:
# Could not find a fixture with the same name, let's see if there is a parser involved
name = find_argumented_step_fixture_name(name, step.type, request._fixturemanager, request)
if name:
return request.getfixturevalue(name)
raise
except FixtureLookupError:
raise exceptions.StepDefinitionNotFoundError(
f"Step definition is not found: {step}. "
f'Line {step.line_number} in scenario "{scenario.name}" in the feature "{scenario.feature.filename}"' )
E pytest_bdd.exceptions.StepDefinitionNotFoundError: Step definition is not found: Given "I have a first John contact". Line 6 in scenario "Listing Added Contacts" in the feature "C:\Working\gitea\Learn_Python_TDD_packt\Crafting-Test-Driven-Software-with-Python\Source_Code\Chapter07\tests\acceptance\list_contacts.feature"
C:\bin\python\python-3.9.5\lib\site-packages\pytest_bdd\scenario.py:86: StepDefinitionNotFoundError
=============================================== short test summary info ================================================
FAILED tests/functional/test_acceptance.py::test_listing_added_contacts[Mario-Luigi-Mario,Luigi] - pytest_bdd.exceptio...FAILED tests/functional/test_acceptance.py::test_listing_added_contacts[John-Jane-John,Jane] - pytest_bdd.exceptions.S...============================================= 2 failed, 21 passed in 1.33s =============================================
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.