File: pytest_plugin_validate.py

package info (click to toggle)
python-gsd 3.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,020 kB
  • sloc: python: 3,141; ansic: 2,057; cpp: 120; makefile: 16
file content (37 lines) | stat: -rw-r--r-- 1,001 bytes parent folder | download
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
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright (c) 2016-2024 The Regents of the University of Michigan
# Part of GSD, released under the BSD 2-Clause License.

"""Command line options for pytest."""

import pytest


def pytest_addoption(parser):
    """Add GSD specific options to the pytest command line.

    * validate - run validation tests
    """
    parser.addoption(
        '--validate',
        action='store_true',
        default=False,
        help='Enable long running validation tests.',
    )


@pytest.fixture(autouse=True)
def _skip_validate(request):
    """Skip validation tests by default.

    Pass the command line option --validate to enable these tests.
    """
    if request.node.get_closest_marker('validate'):
        if not request.config.getoption('validate'):
            pytest.skip('Validation tests not requested.')


def pytest_configure(config):
    """Define the ``validate`` marker."""
    config.addinivalue_line(
        'markers', 'validate: Tests that perform long-running validations.'
    )