Skip to content

Commit

Permalink
Mark tests as 'avoidable' to prevent them from running on Github
Browse files Browse the repository at this point in the history
  • Loading branch information
squillero committed Aug 23, 2023
1 parent 2df990c commit 245a6f2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions test/runs/test_evaluators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'):
Expand Down

0 comments on commit 245a6f2

Please sign in to comment.