python -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txtpytest
or
python -m pytest tests/
tests/test_app.py
from app import foo
def test_foo():
assert foo() is False, "first test must fail"app.py
def foo():
return Falsetests/conftest.py
import pytest
@pytest.fixture()
def demo_fixture():
return 1Using fixture in test
tests/test_app.py
def test_fixture(demo_fixture):
assert 1 == demo_fixture, "fixture demo"tests/test_app.py
import pytest
testdata = [
("0", 0),
("1", 1),
("2", 2),
]
@pytest.mark.parametrize("actual, expected", testdata)
def test_parametrize(actual, expected):
assert int(actual) == expected