diff --git a/test/conftest.py b/test/conftest.py new file mode 100644 index 0000000..dc8fac7 --- /dev/null +++ b/test/conftest.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +#################################|###|##################################### +# __ | | # +# | |--.--.--.----.-----.-----. |===| This file is part of Byron v0.8 # +# | _ | | | _| _ | | |___| An evolutionary optimizer & fuzzer # +# |_____|___ |__| |_____|__|__| ).( https://github.com/squillero/byron # +# |_____| \|/ # +################################## ' ###################################### +# Copyright 2023 Giovanni Squillero and Alberto Tonda +# SPDX-License-Identifier: Apache-2.0 +import pytest + + +def pytest_addoption(parser): + parser.addoption("--all", action="store_true", default=False, help="run all tests (including 'avoidable' ones)") + + +def pytest_configure(config): + config.addinivalue_line("markers", "avoidable: mark test as avoidable (require --all)") + + +def pytest_collection_modifyitems(config, items): + if config.getoption("--all"): + return + skip_avoidable = pytest.mark.skip(reason="need --all option to run") + for item in items: + if "avoidable" in item.keywords: + item.add_marker(skip_avoidable) diff --git a/test/runs/test_evaluators.py b/test/runs/test_evaluators.py index bf561b1..e0423b1 100644 --- a/test/runs/test_evaluators.py +++ b/test/runs/test_evaluators.py @@ -10,6 +10,8 @@ # Copyright 2023 Giovanni Squillero and Alberto Tonda # SPDX-License-Identifier: Apache-2.0 +import pytest + import logging import itertools import os @@ -25,6 +27,7 @@ def fitness(genotype): return sum(b == '1' for b in genotype) +@pytest.mark.avoidable def test_evaluators(): assert os.path.exists('runs') or os.path.exists('test/runs') if os.path.exists('test/runs'):