Skip to content
Snippets Groups Projects
Commit 950f32f5 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[test] Add missing conftest for pytest

parent f7194494
No related branches found
No related tags found
1 merge request!16Use pytest instead of nose
Pipeline #45681 failed
#!/usr/bin/env python
# coding=utf-8
import pytest
import bob.extension
def pytest_configure(config):
"""This function is run once for pytest setup"""
config.addinivalue_line(
"markers",
"skip_if_rc_var_not_set(name): this mark skips the test if a certain "
"~/.bobrc variable is not set",
)
config.addinivalue_line("markers", "slow: this mark indicates slow tests")
def pytest_runtest_setup(item):
"""This function is run for every test candidate in this directory
The test is run if this function returns ``None``. To skip a test, call
``pytest.skip()``, specifying a reason.
"""
# iterates over all markers for the item being examined, get the first
# argument and accumulate these names
rc_names = [
mark.args[0]
for mark in item.iter_markers(name="skip_if_rc_var_not_set")
]
# checks all names mentioned are set in ~/.bobrc, otherwise, skip the test
if rc_names:
missing = [k for k in rc_names if (k not in bob.extension.rc)]
if any(missing):
pytest.skip(f"Test skipped because {', '.join(missing)} are **not** "
f"set in ~/.bobrc")
def rc_variable_set(name):
pytest.mark.skipif(
name not in bob.extension.rc,
reason=f"Bob's RC variable '{name}' is not set",
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment