Why do I get this error depending on the function name? #9035
Answered
by
Zac-HD
sanghyuckNa
asked this question in
Q&A
-
### unit_test.py ###
def test(x):
return x + 1
def test_answer():
assert test(3) == 4 $ pytest unit_test.py
----------------------------------------------------------------------------------
collected 2 items
def test(x):
E fixture 'x' not found
1 passed, 1 error ### other code ###
def func(x):
return x + 1
def test_answer():
assert func(3) == 4 collected 1 items
1 passed I don't understand. only function name is different. but result is different. |
Beta Was this translation helpful? Give feedback.
Answered by
Zac-HD
Aug 25, 2021
Replies: 1 comment
-
In your first example, pytest collects the function named |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Zac-HD
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In your first example, pytest collects the function named
test
as a test function and then errors because it has an argument namedx
but there is no corresponding fixture. In the second example,func
is not collected as a test.