* [gentoo-commits] proj/portage:master commit in: lib/portage/tests/util/, lib/portage/tests/util/file_copy/, ...
@ 2023-05-26 15:45 Sam James
0 siblings, 0 replies; only message in thread
From: Sam James @ 2023-05-26 15:45 UTC (permalink / raw
To: gentoo-commits
commit: 2439754cee568a972961501771e283f847e36c3c
Author: David Palao <david.palao <AT> gmail <DOT> com>
AuthorDate: Fri May 19 12:41:26 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 26 15:44:37 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=2439754c
tests: runtests: use diff test logic w/ runtests and w/ pytest
...in three cases that were causing errors or failures with runtest
but passing smoothly with pytest.
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 | 13 +++++++++++++
lib/portage/tests/util/file_copy/test_copyfile.py | 12 ++++++++----
lib/portage/tests/util/test_whirlpool.py | 12 +++++++++---
3 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/lib/portage/tests/process/test_unshare_net.py b/lib/portage/tests/process/test_unshare_net.py
index 7910e1553..da5761cd1 100644
--- a/lib/portage/tests/process/test_unshare_net.py
+++ b/lib/portage/tests/process/test_unshare_net.py
@@ -33,6 +33,19 @@ class UnshareNetTestCase(TestCase):
)
@pytest.mark.skipif(platform.system() != "Linux", reason="not Linux")
def testUnshareNet(self):
+ AM_I_UNDER_PYTEST = "PYTEST_CURRENT_TEST" in os.environ
+ if not AM_I_UNDER_PYTEST:
+ 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(
diff --git a/lib/portage/tests/util/file_copy/test_copyfile.py b/lib/portage/tests/util/file_copy/test_copyfile.py
index 6e5ae9571..22c3982f0 100644
--- a/lib/portage/tests/util/file_copy/test_copyfile.py
+++ b/lib/portage/tests/util/file_copy/test_copyfile.py
@@ -57,13 +57,17 @@ class CopyFileSparseTestCase(TestCase):
# This last part of the test is expected to fail when sparse
# copy is not implemented, so set the todo flag in order
- # to tolerate failures.
- ## self.todo = True
+ # to tolerate failures. Or mark it xfail:
+
+ AM_I_UNDER_PYTEST = "PYTEST_CURRENT_TEST" in os.environ
+
+ if AM_I_UNDER_PYTEST:
+ pytest.xfail(reason="sparse copy is not implemented")
+ else:
+ self.todo = True
# If sparse blocks were preserved, then both files should
# consume the same number of blocks.
-
- pytest.xfail(reason="sparse copy is not implemented")
self.assertEqual(os.stat(src_path).st_blocks, os.stat(dest_path).st_blocks)
finally:
shutil.rmtree(tempdir)
diff --git a/lib/portage/tests/util/test_whirlpool.py b/lib/portage/tests/util/test_whirlpool.py
index 4b3b9edaf..900de4b98 100644
--- a/lib/portage/tests/util/test_whirlpool.py
+++ b/lib/portage/tests/util/test_whirlpool.py
@@ -1,4 +1,4 @@
-# Copyright 2011-2022 Gentoo Authors
+# Copyright 2011-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import pytest
@@ -7,6 +7,10 @@ from portage.tests import TestCase
from portage.util.whirlpool import CWhirlpool, PyWhirlpool
+CWHIRLPOOL_AVAILABLE = CWhirlpool.is_available
+CWHIRLPOOL_NOT_AVAILABLE_MSG = "C Whirlpool extension is not importable"
+
+
class WhirlpoolTestCase(TestCase):
def testBundledWhirlpool(self, cls=PyWhirlpool):
self.assertEqual(
@@ -29,8 +33,10 @@ class WhirlpoolTestCase(TestCase):
)
@pytest.mark.skipif(
- not CWhirlpool.is_available,
- reason="C Whirlpool extension is not importable",
+ not CWHIRLPOOL_AVAILABLE,
+ reason=CWHIRLPOOL_NOT_AVAILABLE_MSG,
)
def testCWhirlpool(self):
+ if not CWHIRLPOOL_AVAILABLE:
+ self.skipTest(CWHIRLPOOL_NOT_AVAILABLE_MSG)
self.testBundledWhirlpool(CWhirlpool)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-26 15:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-26 15:45 [gentoo-commits] proj/portage:master commit in: lib/portage/tests/util/, lib/portage/tests/util/file_copy/, Sam James
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox