def pytest_generate_tests(metafunc): """Parametrize tests to run on all backends.""" if 'backend' in metafunc.fixturenames: skip_backends = set() # Skip backends specified on the module level if hasattr(metafunc.module, 'skip_backends'): skip_backends = skip_backends.union(set(metafunc.module.skip_backends)) # Skip backends specified on the class level if hasattr(metafunc.cls, 'skip_backends'): skip_backends = skip_backends.union(set(metafunc.cls.skip_backends)) # Use only backends specified on the command line if any if metafunc.config.option.backend: backend = set([x.lower() for x in metafunc.config.option.backend]) # Otherwise use all available backends # FIXME: This doesn't really work since the list of backends is # dynamically populated as backends are imported else: backend = set(backends.keys()) # Restrict to set of backends specified on the module level if hasattr(metafunc.module, 'backends'): backend = backend.intersection(set(metafunc.module.backends)) # Restrict to set of backends specified on the class level if hasattr(metafunc.cls, 'backends'): backend = backend.intersection(set(metafunc.cls.backends)) # Allow skipping individual backends by passing skip_<backend> as a parameter backend = [b for b in backend.difference(skip_backends) \ if not 'skip_'+b in metafunc.fixturenames] metafunc.parametrize("backend", backend, indirect=True)
def pytest_addoption(parser): parser.addoption("--backend", action="append", help="Selection the backend: one of %s" % backends.keys()) parser.addoption("--lazy", action="store_true", help="Only run lazy mode") parser.addoption("--greedy", action="store_true", help="Only run greedy mode")
def pytest_generate_tests(metafunc): """Parametrize tests to run on all backends.""" if 'backend' in metafunc.fixturenames: skip_backends = set() # Skip backends specified on the module level if hasattr(metafunc.module, 'skip_backends'): skip_backends = skip_backends.union( set(metafunc.module.skip_backends)) # Skip backends specified on the class level if hasattr(metafunc.cls, 'skip_backends'): skip_backends = skip_backends.union(set( metafunc.cls.skip_backends)) # Use only backends specified on the command line if any if metafunc.config.option.backend: backend = set([x.lower() for x in metafunc.config.option.backend]) # Otherwise use all available backends # FIXME: This doesn't really work since the list of backends is # dynamically populated as backends are imported else: backend = set(backends.keys()) # Restrict to set of backends specified on the module level if hasattr(metafunc.module, 'backends'): backend = backend.intersection(set(metafunc.module.backends)) # Restrict to set of backends specified on the class level if hasattr(metafunc.cls, 'backends'): backend = backend.intersection(set(metafunc.cls.backends)) # It is preferable to run in greedy mode first, in # case some test create leftover computations lazy = [] # Skip greedy execution by passing skip_greedy as a parameter if not ('skip_greedy' in metafunc.fixturenames or metafunc.config.option.lazy): lazy.append('greedy') # Skip lazy execution by passing skip_greedy as a parameter if not ('skip_lazy' in metafunc.fixturenames or metafunc.config.option.greedy): lazy.append('lazy') # Allow skipping individual backends by passing skip_<backend> as a # parameter backend = [ b for b in backend.difference(skip_backends) if not 'skip_' + b in metafunc.fixturenames ] params = list(product(backend, lazy)) metafunc.parametrize('backend', params or [(None, None)], indirect=True, ids=['-'.join(p) for p in params])
def pytest_generate_tests(metafunc): """Parametrize tests to run on all backends.""" if 'backend' in metafunc.fixturenames: skip_backends = set() # Skip backends specified on the module level if hasattr(metafunc.module, 'skip_backends'): skip_backends = skip_backends.union( set(metafunc.module.skip_backends)) # Skip backends specified on the class level if hasattr(metafunc.cls, 'skip_backends'): skip_backends = skip_backends.union( set(metafunc.cls.skip_backends)) # Use only backends specified on the command line if any if metafunc.config.option.backend: backend = set([x.lower() for x in metafunc.config.option.backend]) # Otherwise use all available backends # FIXME: This doesn't really work since the list of backends is # dynamically populated as backends are imported else: backend = set(backends.keys()) # Restrict to set of backends specified on the module level if hasattr(metafunc.module, 'backends'): backend = backend.intersection(set(metafunc.module.backends)) # Restrict to set of backends specified on the class level if hasattr(metafunc.cls, 'backends'): backend = backend.intersection(set(metafunc.cls.backends)) # It is preferable to run in greedy mode first, in # case some test create leftover computations lazy = [] # Skip greedy execution by passing skip_greedy as a parameter if not ('skip_greedy' in metafunc.fixturenames or metafunc.config.option.lazy): lazy.append('greedy') # Skip lazy execution by passing skip_greedy as a parameter if not ('skip_lazy' in metafunc.fixturenames or metafunc.config.option.greedy): lazy.append('lazy') # Allow skipping individual backends by passing skip_<backend> as a # parameter backend = [b for b in backend.difference(skip_backends) if not 'skip_' + b in metafunc.fixturenames] params = list(product(backend, lazy)) metafunc.parametrize('backend', params or [(None, None)], indirect=True, ids=['-'.join(p) for p in params])
def pytest_addoption(parser): parser.addoption("--backend", action="append", help="Selection the backend: one of %s" % backends.keys())