commit: 68eec067946997d64462a9d5fe188d1d830ea7a0
Author: David Palao <david.palao <AT> gmail <DOT> com>
AuthorDate: Mon May 1 08:50:15 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 26 15:44:36 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=68eec067
tests: process: port testUnshareNet to pytest
...using skipif, instead of the old addPortageSkip mechanism.
Signed-off-by: David Palao <david.palao <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/tests/process/test_unshare_net.py | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/lib/portage/tests/process/test_unshare_net.py
b/lib/portage/tests/process/test_unshare_net.py
index 6951faab6..4c70465f8 100644
--- a/lib/portage/tests/process/test_unshare_net.py
+++ b/lib/portage/tests/process/test_unshare_net.py
@@ -5,10 +5,13 @@ import errno
import os
import platform
+import pytest
+
import portage.process
from portage.const import BASH_BINARY
from portage.tests import TestCase
+
CLONE_NEWNET = 0x40000000
UNSHARE_NET_TEST_SCRIPT = """
@@ -19,18 +22,19 @@ ping -c 1 -W 1 ::1 || exit 1
ping -c 1 -W 1 fd::1 || exit 1
"""
+ABILITY_TO_UNSHARE = portage.process._unshare_validate(CLONE_NEWNET)
+
class UnshareNetTestCase(TestCase):
+ @pytest.mark.skipif(platform.system() != "Linux", reason="not Linux")
+ @pytest.mark.skipif(
+ portage.process.find_binary("ping") is None, reason="ping not found"
+ )
+ @pytest.mark.skipif(
+ ABILITY_TO_UNSHARE != 0,
+ reason=f"Unable to unshare: {errno.errorcode.get(ABILITY_TO_UNSHARE,
'?')}",
+ )
def testUnshareNet(self):
- if platform.system() != "Linux":
- self.skipTest("not Linux")
- if portage.process.find_binary("ping") is None:
- self.skipTest("ping not found")
-
- errno_value = portage.process._unshare_validate(CLONE_NEWNET)
- if errno_value != 0:
- self.skipTest(f"Unable to unshare:
{errno.errorcode.get(errno_value, '?')}")
-
env = os.environ.copy()
env["IPV6"] = "1" if portage.process._has_ipv6() else ""
self.assertEqual(