Commit 6a518326 authored by Frédéric Pierret's avatar Frédéric Pierret Committed by Holger Levsen
Browse files

test_reprotest: filter per distribution and register custom marks

parent 0c17de77
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ Depends: ${python3:Depends},
 procps,
 python3-pkg-resources,
 python3-rstr,
 python3-distro,
 ${misc:Depends}
Recommends:
 diffoscope (>= 112~),

tests/conftest.py

0 → 100644
+26 −0
Original line number Diff line number Diff line
import distro
import pytest

SUPPORTED_DIST = ["debian", "fedora"]


def pytest_configure(config):
    config.addinivalue_line(
        "markers", "need_builddeps: need need_builddeps"
    )
    config.addinivalue_line(
        "markers", "debian: filter tests for debian only"
    )
    config.addinivalue_line(
        "markers", "fedora: filter tests for fedora only"
    )


def pytest_runtest_setup(item):
    # get current dist
    dist = distro.id()
    # filter markers
    supported_dist = set(SUPPORTED_DIST).intersection(
        mark.name for mark in item.iter_markers())
    if supported_dist and dist not in supported_dist:
        pytest.skip("cannot run on {}".format(dist))
+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ def test_command_lines():
    assert testbed_args.virtual_server_args == ['schroot', 'unstable-amd64-sbuild']


# TODO: don't call it if we don't have debian/, e.g. for other distros
@pytest.mark.debian
@pytest.mark.need_builddeps
def test_debian_build(virtual_server):
    # This is a bit dirty though it works - when building the debian package,