public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: tests/scripts/
@ 2022-11-19 17:20 Arthur Zamarin
  0 siblings, 0 replies; 3+ messages in thread
From: Arthur Zamarin @ 2022-11-19 17:20 UTC (permalink / raw
  To: gentoo-commits

commit:     d847af4232d5c7ac3965a493732a9d9fd76a37e5
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 19 17:18:49 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 19 17:18:49 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=d847af42

tests/scripts/test_pkgcheck_scan.py: fix NOCOLOR test

Fix the test for systems which predefine NOCOLOR, like in case of ebuild
test environment (by epytest).

Follows: d77990efa1b8a2151471e8e112b36b048b25ea54
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 tests/scripts/test_pkgcheck_scan.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/scripts/test_pkgcheck_scan.py b/tests/scripts/test_pkgcheck_scan.py
index 6c1600f8..c224d83a 100644
--- a/tests/scripts/test_pkgcheck_scan.py
+++ b/tests/scripts/test_pkgcheck_scan.py
@@ -271,7 +271,8 @@ class TestPkgcheckScanParseArgs:
         '''))
 
         args = ('scan', '--config', str(config_file))
-        assert parser.parse_args(args).color is True
+        with os_environ('NOCOLOR'):
+            assert parser.parse_args(args).color is True
         with os_environ(NOCOLOR='1'):
             # NOCOLOR overrides config file
             assert parser.parse_args(args).color is False


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: tests/scripts/
@ 2023-09-22 18:43 Arthur Zamarin
  0 siblings, 0 replies; 3+ messages in thread
From: Arthur Zamarin @ 2023-09-22 18:43 UTC (permalink / raw
  To: gentoo-commits

commit:     778814581c921a7189138707305ab5b6a72ed3de
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 22 18:43:25 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Sep 22 18:43:25 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=77881458

tests.test_pkgcheck_scan: fix issues with xdist testing

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 tests/scripts/test_pkgcheck_scan.py | 58 ++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 37 deletions(-)

diff --git a/tests/scripts/test_pkgcheck_scan.py b/tests/scripts/test_pkgcheck_scan.py
index 83ac7760..7f2c71d5 100644
--- a/tests/scripts/test_pkgcheck_scan.py
+++ b/tests/scripts/test_pkgcheck_scan.py
@@ -549,12 +549,7 @@ class TestPkgcheckScan:
             error = exc.stderr if exc.stderr else exc.stdout
             pytest.fail(error)
 
-    # mapping of repos to scanned results
-    _results = {}
-    _verbose_results = {}
-
-    @pytest.mark.parametrize("repo", repos)
-    def test_scan_repo(self, repo, tmp_path, verbosity=0):
+    def _scan_results(self, repo, tmp_path, verbosity):
         """Scan a target repo, saving results for verification."""
         repo_dir = self.repos_dir / repo
 
@@ -584,24 +579,15 @@ class TestPkgcheckScan:
         results = []
         for result in self.scan(self.scan_args + args):
             # ignore results generated from stubs
-            stubs = (getattr(result, x, "") for x in ("category", "package"))
-            if any(x.startswith("stub") for x in stubs):
+            if any(getattr(result, x, "").startswith("stub") for x in ("category", "package")):
                 continue
             results.append(result)
 
-        if verbosity:
-            self._verbose_results[repo] = set(results)
-            assert len(results) == len(self._verbose_results[repo])
-        else:
-            self._results[repo] = set(results)
-            assert len(results) == len(self._results[repo])
-
-    @pytest.mark.parametrize("repo", repos)
-    def test_scan_repo_verbose(self, repo, tmp_path):
-        """Scan a target repo in verbose mode, saving results for verification."""
-        return self.test_scan_repo(repo, tmp_path, verbosity=1)
+        results_set = set(results)
+        assert len(results) == len(results_set)
+        return results_set
 
-    def _get_results(self, path):
+    def _get_results(self, path: str):
         """Return the set of result objects from a given json stream file."""
         try:
             with (self.repos_data / path).open() as f:
@@ -620,14 +606,12 @@ class TestPkgcheckScan:
             return output
 
     @pytest.mark.parametrize("repo", repos)
-    def test_scan_verify(self, repo, tmp_path):
+    def test_scan_repo(self, repo, tmp_path_factory):
         """Run pkgcheck against test pkgs in bundled repo, verifying result output."""
         results = set()
         verbose_results = set()
-        if repo not in self._results:
-            self.test_scan_repo(repo, tmp_path, verbosity=0)
-        if repo not in self._verbose_results:
-            self.test_scan_repo(repo, tmp_path, verbosity=1)
+        scan_results = self._scan_results(repo, tmp_path_factory.mktemp("scan"), verbosity=0)
+        scan_verbose_results = self._scan_results(repo, tmp_path_factory.mktemp("ver"), verbosity=1)
         for check, keywords in self._checks[repo].items():
             for keyword in keywords:
                 # verify the expected results were seen during the repo scans
@@ -648,24 +632,24 @@ class TestPkgcheckScan:
                 else:
                     verbose_results.update(expected_results)
 
-        if results != self._results[repo]:
-            missing = self._render_results(results - self._results[repo])
-            unknown = self._render_results(self._results[repo] - results)
-            error = ["unmatched repo scan results:"]
+        if results != scan_results:
+            missing = self._render_results(results - scan_results)
+            unknown = self._render_results(scan_results - results)
+            error = ["unmatched repo scan results:\n\n"]
             if missing:
                 error.append(f"{repo} repo missing expected results:\n{missing}")
             if unknown:
                 error.append(f"{repo} repo unknown results:\n{unknown}")
-            pytest.fail("\n".join(error))
-        if verbose_results != self._verbose_results[repo]:
-            missing = self._render_results(verbose_results - self._verbose_results[repo])
-            unknown = self._render_results(self._verbose_results[repo] - verbose_results)
-            error = ["unmatched verbose repo scan results:"]
+            pytest.fail("\n".join(error), pytrace=False)
+        if verbose_results != scan_verbose_results:
+            missing = self._render_results(verbose_results - scan_verbose_results)
+            unknown = self._render_results(scan_verbose_results - verbose_results)
+            error = ["unmatched verbose repo scan results:\n\n"]
             if missing:
                 error.append(f"{repo} repo missing expected results:\n{missing}")
             if unknown:
                 error.append(f"{repo} repo unknown results:\n{unknown}")
-            pytest.fail("\n".join(error))
+            pytest.fail("\n".join(error), pytrace=False)
 
     @staticmethod
     def _patch(fix, repo_path):
@@ -715,9 +699,9 @@ class TestPkgcheckScan:
 
             results = list(self.scan(self.scan_args + args))
             if results:
-                error = ["unexpected repo scan results:"]
+                error = ["unexpected repo scan results:\n"]
                 error.append(self._render_results(results))
-                pytest.fail("\n".join(error))
+                pytest.fail("\n".join(error), pytrace=False)
 
             shutil.rmtree(fixed_repo)
             tested = True


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: tests/scripts/
@ 2025-06-02 13:16 Arthur Zamarin
  0 siblings, 0 replies; 3+ messages in thread
From: Arthur Zamarin @ 2025-06-02 13:16 UTC (permalink / raw
  To: gentoo-commits

commit:     46a37bb18a13f1ec68273d00524c73e5b91823a0
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat May 31 14:21:10 2025 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Jun  2 13:16:25 2025 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=46a37bb1

tests: Wrap partial() in staticmethod(), in attributes for py3.14

Wrap `partial()` uses in class attributes in `staticmethod()`,
as required for them to work correctly in Python 3.14.

> functools.partial is now a method descriptor. Wrap it in staticmethod()
> if you want to preserve the old behavior.

(https://docs.python.org/3.14/whatsnew/3.14.html#changes-in-the-python-api)

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Part-of: https://github.com/pkgcore/pkgcheck/pull/738
Closes: https://github.com/pkgcore/pkgcheck/pull/738
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 tests/scripts/test_pkgcheck.py       | 4 ++--
 tests/scripts/test_pkgcheck_cache.py | 2 +-
 tests/scripts/test_pkgcheck_ci.py    | 2 +-
 tests/scripts/test_pkgcheck_show.py  | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/scripts/test_pkgcheck.py b/tests/scripts/test_pkgcheck.py
index 21b52424..a5ac7743 100644
--- a/tests/scripts/test_pkgcheck.py
+++ b/tests/scripts/test_pkgcheck.py
@@ -9,7 +9,7 @@ from pkgcheck.scripts import run
 
 def test_script_run(capsys):
     """Test regular code path for running scripts."""
-    script = partial(run, project)
+    script = staticmethod(partial(run, project))
 
     with patch(f"{project}.scripts.import_module") as import_module:
         import_module.side_effect = ImportError("baz module doesn't exist")
@@ -40,7 +40,7 @@ def test_script_run(capsys):
 
 
 class TestPkgcheck:
-    script = partial(run, project)
+    script = staticmethod(partial(run, project))
 
     def test_version(self, capsys):
         with patch("sys.argv", [project, "--version"]):

diff --git a/tests/scripts/test_pkgcheck_cache.py b/tests/scripts/test_pkgcheck_cache.py
index 09c75028..9e0b7e43 100644
--- a/tests/scripts/test_pkgcheck_cache.py
+++ b/tests/scripts/test_pkgcheck_cache.py
@@ -8,7 +8,7 @@ from pkgcheck.scripts import run
 
 
 class TestPkgcheckCache:
-    script = partial(run, project)
+    script = staticmethod(partial(run, project))
 
     @pytest.fixture(autouse=True)
     def _setup(self, testconfig, tmp_path):

diff --git a/tests/scripts/test_pkgcheck_ci.py b/tests/scripts/test_pkgcheck_ci.py
index 6530c0f0..9c32f31c 100644
--- a/tests/scripts/test_pkgcheck_ci.py
+++ b/tests/scripts/test_pkgcheck_ci.py
@@ -9,7 +9,7 @@ from pkgcore.ebuild.cpv import VersionedCPV
 
 
 class TestPkgcheckCi:
-    script = partial(run, "pkgcheck")
+    script = staticmethod(partial(run, "pkgcheck"))
 
     @pytest.fixture(autouse=True)
     def _setup(self, testconfig, tmp_path):

diff --git a/tests/scripts/test_pkgcheck_show.py b/tests/scripts/test_pkgcheck_show.py
index 26677059..cc48e67a 100644
--- a/tests/scripts/test_pkgcheck_show.py
+++ b/tests/scripts/test_pkgcheck_show.py
@@ -10,7 +10,7 @@ from pkgcheck.scripts import run
 
 
 class TestPkgcheckShow:
-    script = partial(run, project)
+    script = staticmethod(partial(run, project))
 
     @pytest.fixture(autouse=True)
     def _setup(self, testconfig):


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-02 13:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-02 13:16 [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: tests/scripts/ Arthur Zamarin
  -- strict thread matches above, loose matches on Subject: below --
2023-09-22 18:43 Arthur Zamarin
2022-11-19 17:20 Arthur Zamarin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox