I'm using pytest
, but in this project, the tests are in the regular modules, not modules labeled test_stuff.py
I tried to change the test discovery by adding a pytest.ini
file in the root of my project with the following contents:
[pytest]
python_files = *.py
python_functions=test_*
When I run the tests, still nothing is found:
$ py.test
================================ test session starts ================================
platform linux2 -- Python 2.7.6 -- py-1.4.20 -- pytest-2.5.2
collected 0 items
================================= in 0.03 seconds ==================================
My layout could hardly be simpler:
$ ls
foo.py
pytest.ini
Where foo.py
contains:
def add(a, b):
return a+b
def test_add():
assert 4 == add(2, 2)
Upgrade!
$ sudo pip install pytest --upgrade
This setup works with pytest 2.8, fails with 2.5.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.