From e553b5282ea392e5ae3034a1c295655751db06a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 19 Apr 2026 16:15:34 +0200 Subject: [PATCH] test(pytest): skip instead of xfail where appropriate Skippingisappropriateforcaseswherethere'snopointinrunningthetestsforsome reasonwecandetect,whereasexpectingfailureismorelikeaTODOthing--knownbug oramissingfeature. Refhttps://docs.pytest.org/en/stable/how-to/skipping.html --- test/t/test_chown.py | 2 +- test/t/test_dict.py | 4 ++-- test/t/test_dpkg_query.py | 2 +- test/t/test_ether_wake.py | 2 +- test/t/test_gkrellm.py | 2 +- test/t/test_ifdown.py | 4 ++-- test/t/test_ifup.py | 4 ++-- test/t/test_invoke_rc_d.py | 2 +- test/t/test_postfix.py | 2 +- test/t/test_service.py | 2 +- test/t/unit/test_unit_compgen_ip_addresses.py | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/t/test_chown.py b/test/t/test_chown.py index ee81346d188..5421c5327ec 100644 --- a/test/t/test_chown.py +++ b/test/t/test_chown.py @@ -12,7 +12,7 @@ ) ) class TestChown: - @pytest.mark.xfail( + @pytest.mark.skipif( getpass.getuser() != "root", reason="Only root can chown to all users" ) @pytest.mark.complete("chown ") diff --git a/test/t/test_dict.py b/test/t/test_dict.py index 64adb54dd36..b8070de924f 100644 --- a/test/t/test_dict.py +++ b/test/t/test_dict.py @@ -8,7 +8,7 @@ class TestDict: def test_1(self, completion): assert completion - @pytest.mark.xfail( + @pytest.mark.skipif( os.environ.get("NETWORK") == "none", reason="The database list is unavailable without network", ) @@ -20,7 +20,7 @@ def test_database(self, completion): # completions. assert completion and "_comp_load/" not in completion - @pytest.mark.xfail( + @pytest.mark.skipif( os.environ.get("NETWORK") == "none", reason="The database list is unavailable without network", ) diff --git a/test/t/test_dpkg_query.py b/test/t/test_dpkg_query.py index 743d6682df5..ab4aa02b9a5 100644 --- a/test/t/test_dpkg_query.py +++ b/test/t/test_dpkg_query.py @@ -9,7 +9,7 @@ class TestDpkgQuery: def test_options(self, completion): assert completion - @pytest.mark.xfail( + @pytest.mark.skipif( not os.path.exists("/etc/debian_version"), reason="Likely fails on systems not based on Debian", ) diff --git a/test/t/test_ether_wake.py b/test/t/test_ether_wake.py index 7afe2862125..7457000e649 100644 --- a/test/t/test_ether_wake.py +++ b/test/t/test_ether_wake.py @@ -5,7 +5,7 @@ @pytest.mark.bashcomp(cmd="ether-wake") class TestEtherWake: - @pytest.mark.xfail( + @pytest.mark.skipif( os.environ.get("NETWORK") == "none", reason="MAC addresses may be N/A with no networking configured", ) diff --git a/test/t/test_gkrellm.py b/test/t/test_gkrellm.py index fdc2e165372..ddd3372cd66 100644 --- a/test/t/test_gkrellm.py +++ b/test/t/test_gkrellm.py @@ -3,7 +3,7 @@ import pytest -@pytest.mark.xfail(not os.environ.get("DISPLAY"), reason="X display required") +@pytest.mark.skipif(not os.environ.get("DISPLAY"), reason="X display required") class TestGkrellm: @pytest.mark.complete("gkrellm -", require_cmd=True) def test_1(self, completion): diff --git a/test/t/test_ifdown.py b/test/t/test_ifdown.py index f36456c1c6d..51cda46b2f9 100644 --- a/test/t/test_ifdown.py +++ b/test/t/test_ifdown.py @@ -6,11 +6,11 @@ class TestIfdown: - @pytest.mark.xfail( + @pytest.mark.skipif( os.environ.get("NETWORK") == "none", reason="There won't be any configured interfaces without network", ) - @pytest.mark.xfail(in_container(), reason="Probably fails in a container") + @pytest.mark.skipif(in_container(), reason="Probably fails in a container") @pytest.mark.complete("ifdown ", require_cmd=True) def test_1(self, completion): assert completion diff --git a/test/t/test_ifup.py b/test/t/test_ifup.py index 36752703e8f..df28c216211 100644 --- a/test/t/test_ifup.py +++ b/test/t/test_ifup.py @@ -6,11 +6,11 @@ class TestIfup: - @pytest.mark.xfail( + @pytest.mark.skipif( os.environ.get("NETWORK") == "none", reason="There won't be any configured interfaces without network", ) - @pytest.mark.xfail(in_container(), reason="Probably fails in a container") + @pytest.mark.skipif(in_container(), reason="Probably fails in a container") @pytest.mark.complete("ifup ", require_cmd=True) def test_1(self, completion): assert completion diff --git a/test/t/test_invoke_rc_d.py b/test/t/test_invoke_rc_d.py index 5ef768c64d8..500ee5e61eb 100644 --- a/test/t/test_invoke_rc_d.py +++ b/test/t/test_invoke_rc_d.py @@ -5,7 +5,7 @@ @pytest.mark.bashcomp(cmd="invoke-rc.d") class TestInvokeRcD: - @pytest.mark.xfail( + @pytest.mark.skipif( sys.platform == "darwin", reason="Service completion not available on macOS", ) diff --git a/test/t/test_postfix.py b/test/t/test_postfix.py index 10020b0b2b3..9ebea6dd90c 100644 --- a/test/t/test_postfix.py +++ b/test/t/test_postfix.py @@ -8,7 +8,7 @@ class TestPostfix: def test_1(self, completion): assert completion - @pytest.mark.xfail( + @pytest.mark.skipif( getpass.getuser() != "root", reason="Likely outputs usage only for root", ) diff --git a/test/t/test_service.py b/test/t/test_service.py index 145a33da264..27415f3d129 100644 --- a/test/t/test_service.py +++ b/test/t/test_service.py @@ -6,7 +6,7 @@ class TestService: - @pytest.mark.xfail( + @pytest.mark.skipif( sys.platform == "darwin", reason="Service completion not available on macOS", ) diff --git a/test/t/unit/test_unit_compgen_ip_addresses.py b/test/t/unit/test_unit_compgen_ip_addresses.py index 90c4b47bc4f..518e83cd8d9 100644 --- a/test/t/unit/test_unit_compgen_ip_addresses.py +++ b/test/t/unit/test_unit_compgen_ip_addresses.py @@ -41,7 +41,7 @@ def test_3(self, functions, completion): assert completion assert all("." in x for x in completion) - @pytest.mark.xfail(in_container(), reason="Probably fails in a container") + @pytest.mark.skipif(in_container(), reason="Probably fails in a container") @pytest.mark.complete("ia6 ") def test_4(self, functions, completion): """_comp_compgen_ip_addresses -6 should complete ipv6 addresses."""