Skip to content

Move adding --internet-tests option back to conftest.py #685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest

# Command line options for pytest must be added from conftest.py from where
# `pytest` is called.
def pytest_addoption(parser):
parser.addoption(
"--internet-tests",
action="store_true",
default=False,
help="Run tests that retrieve stuff from the internet. This increases test time.",
)


def pytest_collection_modifyitems(config, items):
run_internet = config.getoption("--internet-tests")
skip_internet = pytest.mark.skip(reason="need --internet-tests option to run")
for item in items:
# All tests marked with `pytest.mark.internet` get skipped unless
# `--run-internet` passed
if not run_internet and ("internet" in item.keywords):
item.add_marker(skip_internet)
22 changes: 1 addition & 21 deletions scanpy/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,16 @@
from pathlib import Path

import pytest

import matplotlib as mpl
mpl.use('agg')
from matplotlib import pyplot
from matplotlib.testing.compare import compare_images
import pytest

import scanpy

scanpy.settings.verbosity = "hint"


def pytest_addoption(parser):
parser.addoption(
"--internet-tests",
action="store_true",
default=False,
help="Run tests that retrieve stuff from the internet. This increases test time.",
)


def pytest_collection_modifyitems(config, items):
run_internet = config.getoption("--internet-tests")
skip_internet = pytest.mark.skip(reason="need --internet-tests option to run")
for item in items:
# All tests marked with `pytest.mark.internet` get skipped unless
# `--run-internet` passed
if not run_internet and ("internet" in item.keywords):
item.add_marker(skip_internet)


def make_comparer(path_expected: Path, path_actual: Path, *, tol: int):
def save_and_compare(basename, tolerance=None):
path_actual.mkdir(parents=True, exist_ok=True)
Expand Down