Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python pytest use same tests for multiple modules

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...
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #pytest #tests #multiple #modules
ADD COMMENT
Topic
Name
7+3 =