Misleading error message when parameters are missing in the parametrize but presented in the test function
See original GitHub issue- a detailed description of the bug or problem you are having
- output of
pip list
from the virtual environment you are using - pytest and operating system versions
- minimal example if possible
I’m using pytest version 6.2.4. Say we have the following function and a corresponding test function:
# ./add.py
def add(n1, n2):
return n1 + n2
# ./test_add.py
@pytest.mark.parametrize(
"arg1, expected_answer",
[pytest.param(2, 3, 5)]
)
def test_add(arg1, arg2, expected_answer):
assert add(arg1, arg2) == expected_answer
Running pytest ./test_add.py::test_add
logs the following error message:
ERROR: not found: ./test_add.py::test_add
(no name './test_add.py::test_add' in any of [<Module test_add.py>])
But actually it fails because arg2
is not presented in the parametrize decorator.
Similar issue when the argument name is wrong.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
unit testing with pytest parametrize - python - Stack Overflow
parametrize on unittest.TestCase methods . PyTest has no way to pass in the parameter. Just do: @pytest.mark.parametrize( ...
Read more >Parametrizing tests — pytest documentation
Generating parameters combinations, depending on command line¶. Let's say we want to execute a test with different computation parameters and the parameter ......
Read more >Advanced googletest Topics
This document will show you more assertions as well as how to construct complex failure messages, propagate fatal failures, reuse and speed up...
Read more >Parameterize BDD Tests | TestComplete Documentation
Let's create a BDD scenario for this task. In BDD tests, you parameterize test steps, not scenarios or features. That is, you set...
Read more >JUnit 5 Tutorial: Writing Parameterized Tests - Petri Kainulainen
This annotation identifies parameterized test methods. Provide the method parameters which are passed to our test method. Because our test ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was able to duplicate the error. Working to fix the error message.
This is the full output:
seems quite clear from that what the error is, no?