aboutsummaryrefslogtreecommitdiff
blob: 527754c8c2cab9a748ee83048120df778371e1a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from functools import partial

import pytest


def pytest_addoption(parser):
    parser.addoption(
        "--network",
        action="store_true",
        dest="network",
        default=False,
        help="allow network related tests to run",
    )


def mark_network(config, func):
    """Decorator to add a 'net' mark and skip the test unless --network is passed."""
    skip_func = pytest.mark.skipif(
        not config.option.network, reason="needs --network option to run"
    )
    return skip_func(pytest.mark.net(func))


def pytest_configure(config):
    pytest.mark_network = partial(mark_network, config)