From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/tests/emerge/
Date: Mon, 30 Oct 2023 03:14:28 +0000 (UTC) [thread overview]
Message-ID: <1698635663.33fd1883b4099965dd3f885ab8d8850b6ea6040c.sam@gentoo> (raw)
commit: 33fd1883b4099965dd3f885ab8d8850b6ea6040c
Author: David Palao <david.palao <AT> gmail <DOT> com>
AuthorDate: Fri Jul 7 15:15:51 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Oct 30 03:14:23 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=33fd1883
tests/emerge: test_simple.py, conftest.py: Refactor
Refactor:
- _TEST_COMMAND_*NAMES -> _SIMPLE_COMMAND_*SEQUENCE
- Added NOOP
- defined global constant
Signed-off-by: David Palao <david.palao <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/tests/emerge/conftest.py | 53 +++++++++++++++++----------------
lib/portage/tests/emerge/test_simple.py | 12 ++++----
2 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/lib/portage/tests/emerge/conftest.py b/lib/portage/tests/emerge/conftest.py
index 7675d4c78c..9cb4691f56 100644
--- a/lib/portage/tests/emerge/conftest.py
+++ b/lib/portage/tests/emerge/conftest.py
@@ -177,26 +177,7 @@ _INSTALLED_EBUILDS = {
},
}
-
-# class SimpleTestCommand:
-# """A class that represents a simple test case command,
-# including post checks, preparation and cleanup.
-# """
-# def __init__(self, command, *options, environment=None):
-# self._command = command
-# self._options = options
-# if environment is None:
-# environment = {}
-# self.environment = environment
-
-# def prepare(self):
-# ...
-
-# def cleanup(self):
-# ...
-
-
-_TEST_COMMAND_NAMES_FETCHCOMMAND = [
+_SIMPLE_COMMAND_FETCHCOMMAND_SEQUENCE = [
"mv {pkgdir} {binhost_dir}",
"emerge -eG dev-libs/A",
"rm -R {pkgdir}",
@@ -208,7 +189,7 @@ _TEST_COMMAND_NAMES_FETCHCOMMAND = [
"mv {binhost_dir} {pkgdir}",
]
-_TEST_COMMAND_NAMES = [
+_SIMPLE_COMMAND_SEQUENCE = [
"emerge -1 dev-libs/A -v dev-libs/B",
"emerge --root --quickpkg-direct-root",
"emerge --quickpkg-direct-root",
@@ -295,12 +276,32 @@ _TEST_COMMAND_NAMES = [
"EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/B",
"ROOT={cross_root} emerge dev-libs/B",
"portageq has_version {cross_eroot} dev-libs/B",
-] + _TEST_COMMAND_NAMES_FETCHCOMMAND
+] + _SIMPLE_COMMAND_FETCHCOMMAND_SEQUENCE
+
+NOOP = lambda: ...
+
+
+# class SimpleTestCommand:
+# """A class that represents a simple test case command,
+# including post checks, preparation and cleanup.
+# """
+# def __init__(self, command, *options, environment=None):
+# self._command = command
+# self._options = options
+# if environment is None:
+# environment = {}
+# self.environment = environment
+
+# def prepare(self):
+# ...
+
+# def cleanup(self):
+# ...
def pytest_generate_tests(metafunc):
if "simple_command" in metafunc.fixturenames:
- metafunc.parametrize("simple_command", _TEST_COMMAND_NAMES, indirect=True)
+ metafunc.parametrize("simple_command", _SIMPLE_COMMAND_SEQUENCE, indirect=True)
def _have_python_xml():
@@ -482,7 +483,7 @@ def simple_command(playground, binhost, request):
"dev-libs/A",
)
else:
- parse_intermixed_command = lambda: ...
+ parse_intermixed_command = NOOP
test_commands["emerge -1 dev-libs/A -v dev-libs/B"] = parse_intermixed_command
test_commands["emerge --root --quickpkg-direct-root"] = emerge_cmd + (
@@ -792,8 +793,8 @@ def simple_command(playground, binhost, request):
fetchcommand = portage.util.shlex_split(settings["FETCHCOMMAND"])
fetch_bin = portage.process.find_binary(fetchcommand[0])
if fetch_bin is None:
- for command_name in _TEST_COMMAND_NAMES_FETCHCOMMAND:
- test_commands[command_name] = lambda: ...
+ for command_name in _SIMPLE_COMMAND_FETCHCOMMAND_SEQUENCE:
+ test_commands[command_name] = NOOP
else:
test_commands["mv {pkgdir} {binhost_dir}"] = lambda: os.rename(
pkgdir, binhost_dir
diff --git a/lib/portage/tests/emerge/test_simple.py b/lib/portage/tests/emerge/test_simple.py
index 692c6a9cb4..12a16f2d93 100644
--- a/lib/portage/tests/emerge/test_simple.py
+++ b/lib/portage/tests/emerge/test_simple.py
@@ -32,6 +32,11 @@ _METADATA_XML_FILES = (
),
)
+_1Q_2010_UPDATE = """
+slotmove =app-doc/pms-3 2 3
+move dev-util/git dev-vcs/git
+"""
+
@pytest.mark.ft
def test_simple_emerge(async_loop, playground, binhost, simple_command):
@@ -161,12 +166,7 @@ async def _async_test_simple(playground, binhost, command, metadata_xml_files, l
with open(os.path.join(test_repo_location, cp, "metadata.xml"), "w") as f:
f.write(playground.metadata_xml_template % xml_data)
with open(os.path.join(updates_dir, "1Q-2010"), "w") as f:
- f.write(
- """
-slotmove =app-doc/pms-3 2 3
-move dev-util/git dev-vcs/git
-"""
- )
+ f.write(_1Q_2010_UPDATE)
if debug:
# The subprocess inherits both stdout and stderr, for
# debugging purposes.
next reply other threads:[~2023-10-30 3:14 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-30 3:14 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-02-25 8:25 [gentoo-commits] proj/portage:master commit in: lib/portage/tests/emerge/ Sam James
2024-02-24 3:36 Zac Medico
2024-01-03 19:59 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-05-26 15:45 Sam James
2023-05-26 15:45 Sam James
2022-09-25 19:12 Mike Gilbert
2021-01-18 12:20 Zac Medico
2020-10-17 9:21 Zac Medico
2020-10-12 18:03 Zac Medico
2020-08-03 23:28 Zac Medico
2020-08-03 19:30 Zac Medico
2020-03-08 22:29 Zac Medico
2020-03-08 7:33 Zac Medico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1698635663.33fd1883b4099965dd3f885ab8d8850b6ea6040c.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox