commit:     e2bd1b3db3fc0f843450daf2bf25d8676963e75b
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 16 05:15:32 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Dec 16 05:34:36 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e2bd1b3d

tests: move CommandStep, FunctionStep to __init__.py

We reinvent this in a few tests so let's share the infra for it. It's
a nice improvement added in 7575302346d29b18cd5d90b7816cc79b86f1cc84.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/tests/__init__.py                   | 13 +++++++++++++
 lib/portage/tests/emaint/test_emaint_binhost.py | 19 ++-----------------
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/lib/portage/tests/__init__.py b/lib/portage/tests/__init__.py
index 79373dfbb0..e06b03c6d7 100644
--- a/lib/portage/tests/__init__.py
+++ b/lib/portage/tests/__init__.py
@@ -8,6 +8,8 @@ import sys
 import time
 import unittest
 from pathlib import Path
+from dataclasses import dataclass
+from typing import Any, Callable, Optional
 
 from unittest.runner import TextTestResult as _TextTestResult
 
@@ -24,6 +26,17 @@ from portage.proxy.objectproxy import ObjectProxy
 # This remains constant when the real value is a mock.
 EPREFIX_ORIG = portage.const.EPREFIX
 
+@dataclass
+class CommandStep:
+    returncode: int
+    command: tuple[str, ...]
+    env: Optional[dict] = None
+    cwd: Optional[str] = None
+
+
+@dataclass
+class FunctionStep:
+    function: Callable[[int], Any]  # called with step index as argument
 
 class lazy_value(ObjectProxy):
     __slots__ = ("_func",)

diff --git a/lib/portage/tests/emaint/test_emaint_binhost.py 
b/lib/portage/tests/emaint/test_emaint_binhost.py
index 8df3576db4..ad536c286d 100644
--- a/lib/portage/tests/emaint/test_emaint_binhost.py
+++ b/lib/portage/tests/emaint/test_emaint_binhost.py
@@ -5,27 +5,12 @@ import os
 import subprocess
 import sys
 import time
-from dataclasses import dataclass
-from typing import Any, Callable, Optional
 
 import portage
-from portage.tests import TestCase
+from portage.tests import TestCase, CommandStep, FunctionStep
 from portage.tests.resolver.ResolverPlayground import ResolverPlayground
 
 
-@dataclass
-class CommandStep:
-    returncode: int
-    command: tuple[str, ...]
-    env: Optional[dict] = None
-    cwd: Optional[str] = None
-
-
-@dataclass
-class FunctionStep:
-    function: Callable[[int], Any]  # called with step index as argument
-
-
 class EmainBinhostTestCase(TestCase):
     def testCompressedIndex(self):
         debug = False
@@ -83,7 +68,7 @@ class EmainBinhostTestCase(TestCase):
                     os.path.exists(bintree._pkgindex_file), f"step {i}"
                 ),
             ),
-            # The compressed index should not exist yet becuase compress-index 
is disabled in make.conf.
+            # The compressed index should not exist yet because compress-index 
is disabled in make.conf.
             FunctionStep(
                 function=lambda i: self.assertFalse(
                     os.path.exists(bintree._pkgindex_file + ".gz"), f"step {i}"

Reply via email to