I am new to pytest and trying to run a simple test to check if pytest works. I'm using windows 10, python 3.8.5 and pytest 6.0.1.
Here is my project directory:
projects/
tests/
__init__.py
test_sample.py
Here is what I put in test_sample.py:
def func(x):
return x + 1
def test_answer():
assert func(3) == 5
if I do the following:
> pytest
the test run fine (1 failed in 0.004s)
> pytest tests/test_sample.py
the test run fine (1 failed in 0.006s)
However, if I do this:
> pytest test_sample.py
It will return a message like this:
no test ran in 0.000s
ERROR: file not found: test_sample.py
I tried deleting __init__.py file but the result was still the same. Also, I have tried this on 2 different computers but nothing changed. In case the problem can't be solved, can I just ignore it and move on with the solutions I'm having?