diff --git a/tests/conftest.py b/tests/conftest.py index e14dc88..142d401 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -20,7 +20,7 @@ def pytest_configure(config): A pytest recognized function to adjust configuration before running tests. """ config.addinivalue_line( - "markers", "github_ci: only to be run in a github ci environment" + "markers", "github_actions: only to be run in a github actions ci environment" ) # These markers are registered to avoid warnings triggered by importing from @@ -37,9 +37,11 @@ def pytest_runtest_setup(item): Several of these tests work against the host system directly, so to protect users from issues we make these not run. """ - if not os.environ("GITHUB_CI"): - has_github_ci_mark = any(mark for mark in item.iter_markers(name="github_ci")) - if has_github_ci_mark: + if not os.environ.get("GITHUB_ACTIONS"): + has_github_actions_mark = any( + mark for mark in item.iter_markers(name="github_actions") + ) + if has_github_actions_mark: pytest.skip("Skipping test marked safe only for GitHub's CI environment.") diff --git a/tests/test_systemd.py b/tests/test_systemd.py index c06c296..2cfdf3f 100644 --- a/tests/test_systemd.py +++ b/tests/test_systemd.py @@ -8,6 +8,8 @@ import tempfile import time +import pytest + from systemdspawner import systemd @@ -22,6 +24,7 @@ def test_get_systemd_version(): ), "Either systemd wasn't running, or we failed to parse the version into an integer!" +@pytest.mark.github_actions async def test_simple_start(): unit_name = "systemdspawner-unittest-" + str(time.time()) await systemd.start_transient_service( @@ -35,6 +38,7 @@ async def test_simple_start(): assert not await systemd.service_running(unit_name) +@pytest.mark.github_actions async def test_service_failed_reset(): """ Test service_failed and reset_service @@ -57,6 +61,7 @@ async def test_service_failed_reset(): assert not await systemd.service_failed(unit_name) +@pytest.mark.github_actions async def test_service_running_fail(): """ Test service_running failing when there's no service. @@ -66,6 +71,7 @@ async def test_service_running_fail(): assert not await systemd.service_running(unit_name) +@pytest.mark.github_actions async def test_env_setting(): unit_name = "systemdspawner-unittest-" + str(time.time()) with tempfile.TemporaryDirectory() as d: @@ -107,6 +113,7 @@ async def test_env_setting(): assert not os.path.exists(env_file) +@pytest.mark.github_actions async def test_workdir(): unit_name = "systemdspawner-unittest-" + str(time.time()) _, env_filename = tempfile.mkstemp() @@ -126,6 +133,7 @@ async def test_workdir(): assert text == d +@pytest.mark.github_actions async def test_slice(): unit_name = "systemdspawner-unittest-" + str(time.time()) _, env_filename = tempfile.mkstemp() @@ -151,6 +159,7 @@ async def test_slice(): assert b"user.slice" in stdout +@pytest.mark.github_actions async def test_properties_string(): """ Test that setting string properties works @@ -180,6 +189,7 @@ async def test_properties_string(): assert text == "/bind-test" +@pytest.mark.github_actions async def test_properties_list(): """ Test setting multiple values for a property @@ -216,6 +226,7 @@ async def test_properties_list(): assert text == d +@pytest.mark.github_actions async def test_uid_gid(): """ Test setting uid and gid diff --git a/tests/test_systemdspawner.py b/tests/test_systemdspawner.py index 668c42c..cd12ca7 100644 --- a/tests/test_systemdspawner.py +++ b/tests/test_systemdspawner.py @@ -59,7 +59,7 @@ def _get_systemdspawner_user_unit(username): return user_unit -@pytest.mark.github_ci +@pytest.mark.github_actions async def test_start_stop(hub_app, systemdspawner_config): """ This tests starts the default user server, access its /api/status endpoint,