diff --git a/tests/conftest.py b/tests/conftest.py index 841693d04b..141994512b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -59,7 +59,7 @@ def pytest_collection_modifyitems(items, config): if config.option.db_backend is DbBackend.SQLITE: if config.option.markexpr != '': # Don't overwrite markers that the user already provided via '-m ' cmdline argument - config.option.markexpr += ' and not requires_psql' + config.option.markexpr += ' and (not requires_psql)' else: config.option.markexpr = 'not requires_psql' @@ -119,7 +119,7 @@ def aiida_profile(pytestconfig, aiida_config, aiida_profile_factory, config_psql marker_opts = pytestconfig.getoption('-m') db_backend = pytestconfig.getoption('--db-backend') - # By default we use RabbitMQ broker and psql_dos storage + # We use RabbitMQ broker by default unless 'presto' marker is specified broker = 'core.rabbitmq' if 'not requires_rmq' in marker_opts or 'presto' in marker_opts: broker = None diff --git a/tests/test_markers.py b/tests/test_markers.py new file mode 100644 index 0000000000..72c75b1544 --- /dev/null +++ b/tests/test_markers.py @@ -0,0 +1,47 @@ +"""Tests markers that have custom logic applied to them""" + +import pytest + + +def test_presto_auto_mark(request): + """Test that the presto marker is added automatically""" + own_markers = [marker.name for marker in request.node.own_markers] + assert len(own_markers) == 1 + assert own_markers[0] == 'presto' + + +@pytest.mark.sphinx +def test_presto_mark_and_another_mark(request): + """Test that presto marker is added even if there is an existing marker (except requires_rmq|psql)""" + own_markers = [marker.name for marker in request.node.own_markers] + + assert len(own_markers) == 2 + assert 'presto' in own_markers + assert 'sphinx' in own_markers + + +@pytest.mark.requires_rmq +def test_no_presto_mark_if_rmq(request): + """Test that presto marker is NOT added if the test is mark with "requires_rmq""" + own_markers = [marker.name for marker in request.node.own_markers] + + assert len(own_markers) == 1 + assert own_markers[0] == 'requires_rmq' + + +@pytest.mark.requires_psql +def test_no_presto_mark_if_psql(request): + """Test that presto marker is NOT added if the test is mark with "requires_psql""" + own_markers = [marker.name for marker in request.node.own_markers] + + assert len(own_markers) == 1 + assert own_markers[0] == 'requires_psql' + + +@pytest.mark.nightly +def test_no_presto_mark_if_nightly(request): + """Test that presto marker is NOT added if the test is mark with "requires_psql""" + own_markers = [marker.name for marker in request.node.own_markers] + + assert len(own_markers) == 1 + assert own_markers[0] == 'nightly'