@pytest.mark.parametrize("input, expected", [
(1, True),
(2, True)
])
def test_check_value(input, expected):
assert input > 0 == expected
py.test tests_directory/foo.py tests_directory/bar.py -k 'test_001 or test_some_other_test'
# content of test_class.py
class TestClass:
def test_one(self):
x = "this"
assert "h" in x
def test_two(self):
x = "hello"
assert hasattr(x, "check")
def pytest_addoption(parser):
parser.addoption("--libname", action="append", default=[],
help="name of the tested library")
def pytest_generate_tests(metafunc):
if 'libname' in metafunc.fixturenames:
metafunc.parametrize("libname", metafunc.config.option.libname)
def test_import(libname):
import importlib
tested_library = importlib.import_module(libname)
# asserts...