* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: tests/config/, tests/ebuild/, tests/util/
@ 2022-10-29 11:59 Arthur Zamarin
0 siblings, 0 replies; only message in thread
From: Arthur Zamarin @ 2022-10-29 11:59 UTC (permalink / raw
To: gentoo-commits
commit: e8f2fec300c71e4ec182987723003dba47b4dc01
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 29 11:59:18 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Oct 29 11:59:18 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=e8f2fec3
tests: small cleanup
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
tests/config/test_cparser.py | 1 -
tests/ebuild/test_cpv.py | 1 -
tests/ebuild/test_eapi.py | 1 -
tests/ebuild/test_ebuild_src.py | 46 +++++++++++++++-------------------------
tests/util/test_parserestrict.py | 45 +++++++++++++++++----------------------
5 files changed, 36 insertions(+), 58 deletions(-)
diff --git a/tests/config/test_cparser.py b/tests/config/test_cparser.py
index b85fb6dc0..648097328 100644
--- a/tests/config/test_cparser.py
+++ b/tests/config/test_cparser.py
@@ -1,4 +1,3 @@
-import sys
import textwrap
from io import StringIO
diff --git a/tests/ebuild/test_cpv.py b/tests/ebuild/test_cpv.py
index 7bd1f67db..72f545bb8 100644
--- a/tests/ebuild/test_cpv.py
+++ b/tests/ebuild/test_cpv.py
@@ -2,7 +2,6 @@ from random import shuffle
import pytest
from pkgcore.ebuild import cpv
-from snakeoil.compatibility import cmp
def generate_misc_sufs():
diff --git a/tests/ebuild/test_eapi.py b/tests/ebuild/test_eapi.py
index 609ebca43..3d1a98585 100644
--- a/tests/ebuild/test_eapi.py
+++ b/tests/ebuild/test_eapi.py
@@ -1,4 +1,3 @@
-from importlib import reload
from unittest import mock
import pytest
diff --git a/tests/ebuild/test_ebuild_src.py b/tests/ebuild/test_ebuild_src.py
index 9d804de47..c05167c5f 100644
--- a/tests/ebuild/test_ebuild_src.py
+++ b/tests/ebuild/test_ebuild_src.py
@@ -260,12 +260,23 @@ class TestBase:
self.get_pkg({'KEYWORDS': '~amd64 ~x86 ~amd64-fbsd'}).sorted_keywords ==
('~amd64', '~x86', '~amd64-fbsd'))
- def generic_check_depends(self, depset, attr, expected=None,
- data_name=None, eapi='0'):
+ @pytest.mark.parametrize(('depset', 'attr', 'expected', 'eapi'), (
+ pytest.param('dev-util/diffball || ( dev-util/foo x86? ( dev-util/bsdiff ) )', 'depend', None, '0', id='depend'),
+ pytest.param('dev-util/diffball || ( dev-util/foo x86? ( dev-util/bsdiff ) )', 'rdepend', None, '0', id='rdepend'),
+ pytest.param('dev-util/diffball x86? ( virtual/boo )', 'pdepend', None, '0', id='pdepend'),
+ # BDEPEND in EAPI 7
+ pytest.param('dev-util/diffball x86? ( virtual/boo )', 'bdepend', None, '7', id='bdepend'),
+ # BDEPEND is ignored in EAPIs <= 6
+ pytest.param('dev-util/diffball x86? ( virtual/boo )', 'bdepend', '', '0', id='no_bdepend'),
+ # IDEPEND in EAPI 8
+ pytest.param('dev-util/diffball x86? ( virtual/boo )', 'idepend', None, '8', id='idepend'),
+ # IDEPEND is ignored in EAPIs <= 7
+ pytest.param('dev-util/diffball x86? ( virtual/boo )', 'idepend', '', '0', id='no_idepend'),
+ ))
+ def test_check_depends(self, depset, attr, expected, eapi):
if expected is None:
expected = depset
- if data_name is None:
- data_name = attr.upper()
+ data_name = attr.upper()
o = self.get_pkg({data_name: depset, 'EAPI': eapi})
assert str(getattr(o, attr)) == expected
o = self.get_pkg({data_name: '', 'EAPI': eapi})
@@ -274,26 +285,6 @@ class TestBase:
with pytest.raises(errors.MetadataException):
getattr(self.get_pkg({data_name: '|| ( ', 'EAPI': eapi}), attr)
- for x in ('depend', 'rdepend'):
- locals()[f'test_{x}'] = post_curry(generic_check_depends,
- 'dev-util/diffball || ( dev-util/foo x86? ( dev-util/bsdiff ) )',
- x)
- del x
- test_pdepend = post_curry(generic_check_depends,
- 'dev-util/diffball x86? ( virtual/boo )', 'pdepend')
- # BDEPEND in EAPI 7
- test_bdepend = post_curry(generic_check_depends,
- 'dev-util/diffball x86? ( virtual/boo )', 'bdepend', eapi='7')
- # BDEPEND is ignored in EAPIs <= 6
- test_no_bdepend = post_curry(generic_check_depends,
- 'dev-util/diffball x86? ( virtual/boo )', 'bdepend', expected='', eapi='0')
- # IDEPEND in EAPI 8
- test_idepend = post_curry(generic_check_depends,
- 'dev-util/diffball x86? ( virtual/boo )', 'idepend', eapi='8')
- # IDEPEND is ignored in EAPIs <= 7
- test_no_idepend = post_curry(generic_check_depends,
- 'dev-util/diffball x86? ( virtual/boo )', 'idepend', expected='', eapi='0')
-
def test_fetchables(self):
l = []
def f(self, cpv, allow_missing=False):
@@ -491,17 +482,14 @@ class TestPackage(TestBase):
return self.get_pkg(
pre_args=(repo_objs.SharedPkgData(metadata_xml, manifest),))
- def generic_metadata_xml(self, attr):
+ @pytest.mark.parametrize("attr", ("longdescription", "maintainers"))
+ def test_metadata_xml(self, attr):
m = repo_objs.MetadataXml(None)
object.__setattr__(m, "_"+attr, "foon")
object.__setattr__(m, "_source", None)
o = self.make_shared_pkg_data(metadata_xml=m)
assert getattr(o, attr) == "foon"
- for x in ("longdescription", "maintainers"):
- locals()[f"test_{x}"] = post_curry(generic_metadata_xml, x)
- del x
-
def test_manifest(self):
m = digest.Manifest(None)
o = self.make_shared_pkg_data(manifest=m)
diff --git a/tests/util/test_parserestrict.py b/tests/util/test_parserestrict.py
index 25dfc0abf..d7331d090 100644
--- a/tests/util/test_parserestrict.py
+++ b/tests/util/test_parserestrict.py
@@ -4,7 +4,6 @@ from pkgcore.ebuild.atom import atom
from pkgcore.repository import util
from pkgcore.restrictions import boolean, packages, restriction, values
from pkgcore.util import parserestrict
-from snakeoil.currying import post_curry
class TestMatch:
@@ -53,22 +52,16 @@ class TestExtendedRestrictionGeneration:
else:
self.verify_text(restrict.restriction, token)
- def generic_single_restrict_check(self, iscat):
- if iscat:
- sfmts = ["%s/*"]
- attr = "category"
- else:
- sfmts = ["*/%s", "%s"]
- attr = "package"
-
- for sfmt in sfmts:
- for raw_token in ("package", "*bsdiff", "bsdiff*"):
- token = sfmt % raw_token
- i = parserestrict.parse_match(token)
- self.verify_restrict(i, attr, raw_token)
-
- test_category = post_curry(generic_single_restrict_check, True)
- test_package = post_curry(generic_single_restrict_check, False)
+ @pytest.mark.parametrize(("attr", "sfmt"), (
+ ("category", "%s/*"),
+ ("package", "*/%s"),
+ ("package", "%s"),
+ ))
+ @pytest.mark.parametrize("raw_token", ("package", "*bsdiff", "bsdiff*"))
+ def test_single_restrict_check(self, raw_token, attr, sfmt):
+ token = sfmt % raw_token
+ i = parserestrict.parse_match(token)
+ self.verify_restrict(i, attr, raw_token)
def test_combined(self):
assert isinstance(parserestrict.parse_match("dev-util/diffball"), atom), "dev-util/diffball"
@@ -175,15 +168,15 @@ class TestExtendedRestrictionGeneration:
assert isinstance(o[1], restricts.SubSlotDep), subslot
self.verify_restrict(o[2], "package", token.split(":")[0])
- def test_exceptions(self):
- for token in (
- "!dev-util/diffball",
- "dev-util/diffball-0.4",
- "=dev-util/*diffball-0.4*",
- "::gentoo",
- ):
- with pytest.raises(parserestrict.ParseError):
- parserestrict.parse_match(token)
+ @pytest.mark.parametrize("token", (
+ "!dev-util/diffball",
+ "dev-util/diffball-0.4",
+ "=dev-util/*diffball-0.4*",
+ "::gentoo",
+ ))
+ def test_exceptions(self, token):
+ with pytest.raises(parserestrict.ParseError):
+ parserestrict.parse_match(token)
class TestParsePV:
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-29 11:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-29 11:59 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: tests/config/, tests/ebuild/, tests/util/ Arthur Zamarin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox