commit: ae5bb29328d709d1b5e5b9f8c8b3e4083a386716
Author: David Palao <david.palao <AT> gmail <DOT> com>
AuthorDate: Fri Jul 7 16:06:20 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Oct 30 03:14:24 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ae5bb293
tests/emerge/conftest.py: Add a new fixture.
Add a new fixture. It adds one more layer of indirection to the
``simple_command`` fixture. Quick benchmarks tell that it is
faster due to pytest caching.
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 | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/lib/portage/tests/emerge/conftest.py
b/lib/portage/tests/emerge/conftest.py
index 656ee85726..07895501d4 100644
--- a/lib/portage/tests/emerge/conftest.py
+++ b/lib/portage/tests/emerge/conftest.py
@@ -387,12 +387,19 @@ def binhost(playground, async_loop):
@pytest.fixture()
-def simple_command(playground, binhost, request):
- """A fixture that provides the commands to perform a baseline
- functional test of portage.
+def _generate_all_simple_commands(playground, binhost):
+ """This fixture generates all the commands that
+ ``test_portage_baseline`` will use.
+
+ But, don't use this fixture directly, instead, use the
+ ``simple_command`` fixture. That improves performance a bit due to
+ pytest caching.
- To add a new command, define it in the local ``test_commands`` and
- add its key to the ``_SIMPLE_COMMAND_SEQUENCE``.
+ .. note::
+
+ To add a new command, define it in the local ``test_commands``
+ dict, if not yet defined, and add its key at the correct position
+ in the ``_SIMPLE_COMMAND_SEQUENCE`` list.
"""
settings = playground.settings
eprefix = settings["EPREFIX"]
@@ -822,4 +829,15 @@ def simple_command(playground, binhost, request):
+ ("-fe", "--getbinpkgonly", "dev-libs/A")
)
- return test_commands[request.param]
+ yield test_commands
+
+
[email protected]()
+def simple_command(request, _generate_all_simple_commands):
+ """A fixture that provides the commands to perform a baseline
+ functional test of portage. It uses another fixture, namely
+ ``_generate_all_simple_commands``.
+ Pytest caches the fixtures and there is a little performance
+ improvement if the commands are generated only once..
+ """
+ return _generate_all_simple_commands[request.param]