aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2022-12-29 19:51:23 +0200
committerArthur Zamarin <arthurzam@gentoo.org>2022-12-29 19:51:23 +0200
commitae7dd4184f63185880738c5133f326fe47c6606a (patch)
treed6d0e55d9684fef5bca6a9035a37763dca8b8402 /tests/checks
parentbump snakeoil minimal version (diff)
downloadpkgcheck-ae7dd4184f63185880738c5133f326fe47c6606a.tar.gz
pkgcheck-ae7dd4184f63185880738c5133f326fe47c6606a.tar.bz2
pkgcheck-ae7dd4184f63185880738c5133f326fe47c6606a.zip
format using black
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'tests/checks')
-rw-r--r--tests/checks/test_acct.py118
-rw-r--r--tests/checks/test_all.py61
-rw-r--r--tests/checks/test_cleanup.py70
-rw-r--r--tests/checks/test_codingstyle.py340
-rw-r--r--tests/checks/test_dropped_keywords.py50
-rw-r--r--tests/checks/test_git.py559
-rw-r--r--tests/checks/test_glsa.py36
-rw-r--r--tests/checks/test_header.py48
-rw-r--r--tests/checks/test_imlate.py111
-rw-r--r--tests/checks/test_metadata.py839
-rw-r--r--tests/checks/test_network.py85
-rw-r--r--tests/checks/test_perl.py50
-rw-r--r--tests/checks/test_pkgdir.py335
-rw-r--r--tests/checks/test_python.py603
-rw-r--r--tests/checks/test_repo.py85
-rw-r--r--tests/checks/test_repo_metadata.py95
-rw-r--r--tests/checks/test_stablereq.py151
-rw-r--r--tests/checks/test_whitespace.py35
18 files changed, 1929 insertions, 1742 deletions
diff --git a/tests/checks/test_acct.py b/tests/checks/test_acct.py
index 57273705..4c8202dc 100644
--- a/tests/checks/test_acct.py
+++ b/tests/checks/test_acct.py
@@ -12,81 +12,86 @@ class TestAcctUser(misc.ReportTestCase):
check_kls = acct.AcctCheck
- kind = 'user'
+ kind = "user"
@pytest.fixture(autouse=True)
def _setup(self, tmp_path):
- (metadata := tmp_path / 'metadata').mkdir()
- (metadata / 'qa-policy.conf').write_text(textwrap.dedent("""\
- [user-group-ids]
- uid-range = 0-749,65534
- gid-range = 0-749,65533,65534
- """))
+ (metadata := tmp_path / "metadata").mkdir()
+ (metadata / "qa-policy.conf").write_text(
+ textwrap.dedent(
+ """\
+ [user-group-ids]
+ uid-range = 0-749,65534
+ gid-range = 0-749,65533,65534
+ """
+ )
+ )
self.location = str(tmp_path)
def mk_check(self, pkgs):
- repo = FakeRepo(pkgs=pkgs, repo_id='test', location=self.location)
+ repo = FakeRepo(pkgs=pkgs, repo_id="test", location=self.location)
check = self.check_kls(arghparse.Namespace(target_repo=repo, gentoo_repo=True))
return check
def mk_pkg(self, name, identifier, version=1, ebuild=None):
if ebuild is None:
- ebuild = textwrap.dedent(f'''\
- inherit acct-{self.kind}
- ACCT_{self.kind.upper()}_ID="{identifier}"
- ''')
- return misc.FakePkg(f'acct-{self.kind}/{name}-{version}', ebuild=ebuild)
+ ebuild = textwrap.dedent(
+ f"""\
+ inherit acct-{self.kind}
+ ACCT_{self.kind.upper()}_ID="{identifier}"
+ """
+ )
+ return misc.FakePkg(f"acct-{self.kind}/{name}-{version}", ebuild=ebuild)
def test_unmatching_pkgs(self):
- pkgs = (misc.FakePkg('dev-util/foo-0'),
- misc.FakePkg('dev-util/bar-1'))
+ pkgs = (misc.FakePkg("dev-util/foo-0"), misc.FakePkg("dev-util/bar-1"))
check = self.mk_check(pkgs)
self.assertNoReport(check, pkgs)
def test_correct_ids(self):
- pkgs = (self.mk_pkg('foo', 100),
- self.mk_pkg('bar', 200),
- self.mk_pkg('test', 749),
- self.mk_pkg('nobody', 65534))
+ pkgs = (
+ self.mk_pkg("foo", 100),
+ self.mk_pkg("bar", 200),
+ self.mk_pkg("test", 749),
+ self.mk_pkg("nobody", 65534),
+ )
check = self.mk_check(pkgs)
self.assertNoReport(check, pkgs)
def test_missing_ids(self):
- pkg = self.mk_pkg('foo', None, ebuild='inherit acct-user\n')
+ pkg = self.mk_pkg("foo", None, ebuild="inherit acct-user\n")
check = self.mk_check((pkg,))
r = self.assertReport(check, pkg)
assert isinstance(r, acct.MissingAccountIdentifier)
- assert r.var == f'ACCT_{self.kind.upper()}_ID'
+ assert r.var == f"ACCT_{self.kind.upper()}_ID"
assert r.var in str(r)
def test_conflicting_ids(self):
- pkgs = (self.mk_pkg('foo', 100),
- self.mk_pkg('bar', 100))
+ pkgs = (self.mk_pkg("foo", 100), self.mk_pkg("bar", 100))
check = self.mk_check(pkgs)
r = self.assertReport(check, pkgs)
assert isinstance(r, acct.ConflictingAccountIdentifiers)
assert r.kind == self.kind
assert r.identifier == 100
- assert r.pkgs == (f'acct-{self.kind}/bar-1', f'acct-{self.kind}/foo-1')
- assert f'conflicting {self.kind} id 100 usage: ' in str(r)
+ assert r.pkgs == (f"acct-{self.kind}/bar-1", f"acct-{self.kind}/foo-1")
+ assert f"conflicting {self.kind} id 100 usage: " in str(r)
def test_self_nonconflicting_ids(self):
- pkgs = (self.mk_pkg('foo', 100),
- self.mk_pkg('foo', 100, version=2))
+ pkgs = (self.mk_pkg("foo", 100), self.mk_pkg("foo", 100, version=2))
check = self.mk_check(pkgs)
self.assertNoReport(check, pkgs)
def test_dynamic_assignment_range(self):
- pkg = self.mk_pkg('foo', 750)
+ pkg = self.mk_pkg("foo", 750)
check = self.mk_check((pkg,))
r = self.assertReport(check, pkg)
assert isinstance(r, acct.OutsideRangeAccountIdentifier)
assert r.kind == self.kind
assert r.identifier == 750
- assert f'{self.kind} id 750 outside permitted' in str(r)
+ assert f"{self.kind} id 750 outside permitted" in str(r)
def test_sysadmin_assignment_range(self):
- pkg = self.mk_pkg('foo', 1000)
+ pkg = self.mk_pkg("foo", 1000)
check = self.mk_check((pkg,))
r = self.assertReport(check, pkg)
assert isinstance(r, acct.OutsideRangeAccountIdentifier)
@@ -94,7 +99,7 @@ class TestAcctUser(misc.ReportTestCase):
assert r.identifier == 1000
def test_high_reserved(self):
- pkg = self.mk_pkg('foo', 65535)
+ pkg = self.mk_pkg("foo", 65535)
check = self.mk_check((pkg,))
r = self.assertReport(check, pkg)
assert isinstance(r, acct.OutsideRangeAccountIdentifier)
@@ -103,7 +108,7 @@ class TestAcctUser(misc.ReportTestCase):
def test_nogroup(self):
"""Test that 65533 is not accepted for UID."""
- pkg = self.mk_pkg('nogroup', 65533)
+ pkg = self.mk_pkg("nogroup", 65533)
check = self.mk_check((pkg,))
r = self.assertReport(check, pkg)
assert isinstance(r, acct.OutsideRangeAccountIdentifier)
@@ -111,28 +116,27 @@ class TestAcctUser(misc.ReportTestCase):
assert r.identifier == 65533
def test_nobody(self):
- pkg = self.mk_pkg('nobody', 65534)
+ pkg = self.mk_pkg("nobody", 65534)
check = self.mk_check((pkg,))
self.assertNoReport(check, pkg)
class TestAcctGroup(TestAcctUser):
- kind = 'group'
+ kind = "group"
def test_nogroup(self):
"""Test that 65533 is accepted for GID."""
- pkg = self.mk_pkg('nogroup', 65533)
+ pkg = self.mk_pkg("nogroup", 65533)
check = self.mk_check((pkg,))
self.assertNoReport(check, pkg)
class TestQaPolicyValidation(misc.ReportTestCase):
-
def mk_check(self, tmp_path, content):
if content:
- (metadata := tmp_path / 'metadata').mkdir()
- (metadata / 'qa-policy.conf').write_text(textwrap.dedent(content))
- repo = FakeRepo(repo_id='test', location=str(tmp_path))
+ (metadata := tmp_path / "metadata").mkdir()
+ (metadata / "qa-policy.conf").write_text(textwrap.dedent(content))
+ repo = FakeRepo(repo_id="test", location=str(tmp_path))
return acct.AcctCheck(arghparse.Namespace(target_repo=repo, gentoo_repo=True))
def test_missing_qa_policy(self, tmp_path):
@@ -141,27 +145,39 @@ class TestQaPolicyValidation(misc.ReportTestCase):
def test_missing_section(self, tmp_path):
with pytest.raises(SkipCheck, match="missing section user-group-ids"):
- self.mk_check(tmp_path, '''\
+ self.mk_check(
+ tmp_path,
+ """\
[random]
x = 5
- ''')
+ """,
+ )
def test_missing_config(self, tmp_path):
with pytest.raises(SkipCheck, match="missing value for gid-range"):
- self.mk_check(tmp_path, '''\
+ self.mk_check(
+ tmp_path,
+ """\
[user-group-ids]
uid-range = 0-749
- ''')
-
- @pytest.mark.parametrize('value', (
- 'start-end',
- '0-749-1500',
- ',150',
- ))
+ """,
+ )
+
+ @pytest.mark.parametrize(
+ "value",
+ (
+ "start-end",
+ "0-749-1500",
+ ",150",
+ ),
+ )
def test_invalid_value(self, tmp_path, value):
with pytest.raises(SkipCheck, match="invalid value for uid-range"):
- self.mk_check(tmp_path, f'''\
+ self.mk_check(
+ tmp_path,
+ f"""\
[user-group-ids]
uid-range = {value}
gid-range = 0-749
- ''')
+ """,
+ )
diff --git a/tests/checks/test_all.py b/tests/checks/test_all.py
index 2ca8a114..a153a802 100644
--- a/tests/checks/test_all.py
+++ b/tests/checks/test_all.py
@@ -22,96 +22,91 @@ class TestMetadataError:
def test_reregister_error(self):
with pytest.raises(ValueError, match="metadata attribute 'eapi' already registered"):
+
class InvalidEapi2(results.MetadataError, results.VersionResult):
- attr = 'eapi'
+ attr = "eapi"
def test_register_missing_attr(self):
with pytest.raises(ValueError, match="class missing metadata attributes"):
+
class InvalidAttr(results.MetadataError, results.VersionResult):
pass
class TestGentooRepoCheck:
-
def test_non_gentoo_repo(self, tool, make_repo):
self.repo = make_repo()
- args = ['scan', '--repo', self.repo.location]
+ args = ["scan", "--repo", self.repo.location]
options, _ = tool.parse_args(args)
- with pytest.raises(checks_mod.SkipCheck, match='not running against gentoo repo'):
+ with pytest.raises(checks_mod.SkipCheck, match="not running against gentoo repo"):
init_check(checks_mod.GentooRepoCheck, options)
def test_gentoo_repo(self, tool, make_repo):
- self.repo = make_repo(repo_id='gentoo')
- args = ['scan', '--repo', self.repo.location]
+ self.repo = make_repo(repo_id="gentoo")
+ args = ["scan", "--repo", self.repo.location]
options, _ = tool.parse_args(args)
assert init_check(checks_mod.GentooRepoCheck, options)
class TestOverlayCheck:
-
def test_non_overlay_repo(self, tool, testconfig):
tool.parser.set_defaults(config_path=testconfig)
- options, _ = tool.parse_args(['scan', '--repo', 'gentoo'])
- with pytest.raises(checks_mod.SkipCheck, match='not running against overlay'):
+ options, _ = tool.parse_args(["scan", "--repo", "gentoo"])
+ with pytest.raises(checks_mod.SkipCheck, match="not running against overlay"):
init_check(checks_mod.OverlayRepoCheck, options)
def test_overlay_repo(self, tool, testconfig):
tool.parser.set_defaults(config_path=testconfig)
- options, _ = tool.parse_args(['scan', '--repo', 'overlay'])
+ options, _ = tool.parse_args(["scan", "--repo", "overlay"])
assert init_check(checks_mod.OverlayRepoCheck, options)
class TestGitCommitsCheck:
-
@pytest.fixture(autouse=True)
def _setup(self, tool, make_repo, make_git_repo):
# initialize parent repo
self.parent_git_repo = make_git_repo()
- self.parent_repo = make_repo(
- self.parent_git_repo.path, repo_id='gentoo', arches=['amd64'])
- self.parent_git_repo.add_all('initial commit')
+ self.parent_repo = make_repo(self.parent_git_repo.path, repo_id="gentoo", arches=["amd64"])
+ self.parent_git_repo.add_all("initial commit")
# initialize child repo
self.child_git_repo = make_git_repo()
- self.child_git_repo.run(['git', 'remote', 'add', 'origin', self.parent_git_repo.path])
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_git_repo.run(['git', 'remote', 'set-head', 'origin', 'main'])
+ self.child_git_repo.run(["git", "remote", "add", "origin", self.parent_git_repo.path])
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_git_repo.run(["git", "remote", "set-head", "origin", "main"])
self.child_repo = make_repo(self.child_git_repo.path)
def test_no_commits_option(self, tool, make_git_repo):
- options, _ = tool.parse_args(
- ['scan', '--repo', self.child_repo.location])
- with pytest.raises(checks_mod.SkipCheck, match='not scanning against git commits'):
+ options, _ = tool.parse_args(["scan", "--repo", self.child_repo.location])
+ with pytest.raises(checks_mod.SkipCheck, match="not scanning against git commits"):
init_check(checks_mod.GitCommitsCheck, options)
def test_commits_option(self, tool, make_repo):
- self.child_repo.create_ebuild('cat/pkg-1')
- self.child_git_repo.add_all('cat/pkg-1')
- options, _ = tool.parse_args(
- ['scan', '--repo', self.child_repo.location, '--commits'])
+ self.child_repo.create_ebuild("cat/pkg-1")
+ self.child_git_repo.add_all("cat/pkg-1")
+ options, _ = tool.parse_args(["scan", "--repo", self.child_repo.location, "--commits"])
assert init_check(checks_mod.GitCommitsCheck, options)
def test_no_local_commits(self, tool):
with pytest.raises(SystemExit) as excinfo:
- tool.parse_args(['scan', '--repo', self.child_repo.location, '--commits'])
+ tool.parse_args(["scan", "--repo", self.child_repo.location, "--commits"])
assert excinfo.value.code == 0
# parent repo has new commits
- self.parent_repo.create_ebuild('cat/pkg-1')
- self.parent_git_repo.add_all('cat/pkg-1')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
+ self.parent_repo.create_ebuild("cat/pkg-1")
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
with pytest.raises(SystemExit) as excinfo:
- tool.parse_args(['scan', '--repo', self.child_repo.location, '--commits'])
+ tool.parse_args(["scan", "--repo", self.child_repo.location, "--commits"])
assert excinfo.value.code == 0
class TestNetworkCheck:
-
def test_network_disabled(self, tool):
- options, _ = tool.parse_args(['scan'])
- with pytest.raises(checks_mod.SkipCheck, match='network checks not enabled'):
+ options, _ = tool.parse_args(["scan"])
+ with pytest.raises(checks_mod.SkipCheck, match="network checks not enabled"):
init_check(checks_mod.NetworkCheck, options)
def test_network_enabled(self, tool):
- options, _ = tool.parse_args(['scan', '--net'])
+ options, _ = tool.parse_args(["scan", "--net"])
assert init_check(checks_mod.NetworkCheck, options)
diff --git a/tests/checks/test_cleanup.py b/tests/checks/test_cleanup.py
index 4e1aa2b3..7ca2f3b6 100644
--- a/tests/checks/test_cleanup.py
+++ b/tests/checks/test_cleanup.py
@@ -3,10 +3,12 @@ from snakeoil.cli import arghparse
from .. import misc
+
def mk_pkg(ver, keywords=("x86", "amd64"), slot="0", **kwds):
return misc.FakePkg(
- f"dev-util/diffball-{ver}",
- data={**kwds, "KEYWORDS": ' '.join(keywords), "SLOT": slot})
+ f"dev-util/diffball-{ver}", data={**kwds, "KEYWORDS": " ".join(keywords), "SLOT": slot}
+ )
+
class TestRedundantVersion(misc.ReportTestCase):
@@ -17,50 +19,43 @@ class TestRedundantVersion(misc.ReportTestCase):
self.assertNoReport(self.check, [mk_pkg("0.7.1")])
def test_live_version(self):
- self.assertNoReport(
- self.check, [mk_pkg('0.7'), mk_pkg('0.9', PROPERTIES='live')])
- self.assertNoReport(
- self.check, [mk_pkg('0.7'), mk_pkg('9999', PROPERTIES='live')])
+ self.assertNoReport(self.check, [mk_pkg("0.7"), mk_pkg("0.9", PROPERTIES="live")])
+ self.assertNoReport(self.check, [mk_pkg("0.7"), mk_pkg("9999", PROPERTIES="live")])
def test_no_keywords(self):
- self.assertNoReport(
- self.check, [mk_pkg('0.7'), mk_pkg('0.9', keywords=())])
+ self.assertNoReport(self.check, [mk_pkg("0.7"), mk_pkg("0.9", keywords=())])
def test_disabled_keywords(self):
- self.assertNoReport(
- self.check, [mk_pkg('0.7'), mk_pkg('0.9', keywords=('-x86', '-amd64'))])
+ self.assertNoReport(self.check, [mk_pkg("0.7"), mk_pkg("0.9", keywords=("-x86", "-amd64"))])
def test_single_redundant(self):
- r = self.assertReport(
- self.check, [mk_pkg(x) for x in ("0.7", "0.8")])
+ r = self.assertReport(self.check, [mk_pkg(x) for x in ("0.7", "0.8")])
assert isinstance(r, cleanup.RedundantVersion)
assert r.later_versions == ("0.8",)
- assert 'slot(0) keywords are overshadowed by version: 0.8' in str(r)
+ assert "slot(0) keywords are overshadowed by version: 0.8" in str(r)
def test_multiple_redundants(self):
- reports = self.assertReports(
- self.check, [mk_pkg(x) for x in ("0.7", "0.8", "0.9")])
- assert (
- [list(x.later_versions) for x in reports] ==
- [["0.8", "0.9"], ["0.9"]])
+ reports = self.assertReports(self.check, [mk_pkg(x) for x in ("0.7", "0.8", "0.9")])
+ assert [list(x.later_versions) for x in reports] == [["0.8", "0.9"], ["0.9"]]
for x in reports:
assert isinstance(x, cleanup.RedundantVersion)
def test_multiple_slots(self):
- l = [mk_pkg("0.7", slot="1"), mk_pkg("0.8"),
- mk_pkg("0.9", slot="1")]
+ l = [mk_pkg("0.7", slot="1"), mk_pkg("0.8"), mk_pkg("0.9", slot="1")]
r = self.assertReport(self.check, l)
assert r.later_versions == ("0.9",)
assert isinstance(r, cleanup.RedundantVersion)
- assert 'slot(1) keywords are overshadowed by version: 0.9' in str(r)
+ assert "slot(1) keywords are overshadowed by version: 0.9" in str(r)
l.append(mk_pkg("0.10", keywords=("x86", "amd64", "~sparc")))
reports = self.assertReports(self.check, l)
- assert ([list(x.later_versions) for x in reports] == [["0.9"], ["0.10"]])
+ assert [list(x.later_versions) for x in reports] == [["0.9"], ["0.10"]]
def test_multiple_keywords(self):
- l = [mk_pkg("0.1", keywords=("~x86", "~amd64")),
- mk_pkg("0.2", keywords=("x86", "~amd64", "~sparc"))]
+ l = [
+ mk_pkg("0.1", keywords=("~x86", "~amd64")),
+ mk_pkg("0.2", keywords=("x86", "~amd64", "~sparc")),
+ ]
r = self.assertReport(self.check, l)
assert r.later_versions == ("0.2",)
@@ -71,32 +66,33 @@ class TestRedundantVersionByStable(misc.ReportTestCase):
check = cleanup.RedundantVersionCheck(arghparse.Namespace(stable_only=True), profile_addon={})
def test_only_unstable(self):
- l = [mk_pkg("0.1", keywords=("~x86", "~amd64")),
- mk_pkg("0.2", keywords=("~x86", "~amd64"))]
+ l = [mk_pkg("0.1", keywords=("~x86", "~amd64")), mk_pkg("0.2", keywords=("~x86", "~amd64"))]
self.assertNoReport(self.check, l)
def test_only_stable(self):
- l = [mk_pkg("0.1", keywords=("x86", "amd64")),
- mk_pkg("0.2", keywords=("x86", "amd64"))]
+ l = [mk_pkg("0.1", keywords=("x86", "amd64")), mk_pkg("0.2", keywords=("x86", "amd64"))]
r = self.assertReport(self.check, l)
assert r.later_versions == ("0.2",)
def test_mixed_stable(self):
- l = [mk_pkg("0.1", keywords=("x86", "amd64", "~sparc")),
- mk_pkg("0.2", keywords=("x86", "amd64", "~sparc"))]
+ l = [
+ mk_pkg("0.1", keywords=("x86", "amd64", "~sparc")),
+ mk_pkg("0.2", keywords=("x86", "amd64", "~sparc")),
+ ]
r = self.assertReport(self.check, l)
assert r.later_versions == ("0.2",)
def test_mixed_history(self):
- l = [mk_pkg("0.1", keywords=("amd64")),
- mk_pkg("0.2", keywords=("~x86", "~amd64")),
- mk_pkg("0.3", keywords=("x86", "amd64")),
- mk_pkg("0.4", keywords=("~x86", "~amd64")),
- mk_pkg("0.5", keywords=("~x86", "~amd64"))]
+ l = [
+ mk_pkg("0.1", keywords=("amd64")),
+ mk_pkg("0.2", keywords=("~x86", "~amd64")),
+ mk_pkg("0.3", keywords=("x86", "amd64")),
+ mk_pkg("0.4", keywords=("~x86", "~amd64")),
+ mk_pkg("0.5", keywords=("~x86", "~amd64")),
+ ]
r = self.assertReport(self.check, l)
assert r.later_versions == ("0.3", "0.4", "0.5")
def test_no_redundant(self):
- l = [mk_pkg("0.1", keywords=("x86", "amd64")),
- mk_pkg("0.2", keywords=("x86", "~amd64"))]
+ l = [mk_pkg("0.1", keywords=("x86", "amd64")), mk_pkg("0.2", keywords=("x86", "~amd64"))]
self.assertNoReport(self.check, l)
diff --git a/tests/checks/test_codingstyle.py b/tests/checks/test_codingstyle.py
index 1c6a0075..528faa8b 100644
--- a/tests/checks/test_codingstyle.py
+++ b/tests/checks/test_codingstyle.py
@@ -30,8 +30,12 @@ class TestInsintoCheck(misc.ReportTestCase):
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
bad = (
- "/etc/env.d", "/etc/conf.d", "/etc/init.d", "/etc/pam.d",
- "/usr/share/applications", "/usr/share/applications",
+ "/etc/env.d",
+ "/etc/conf.d",
+ "/etc/init.d",
+ "/etc/pam.d",
+ "/usr/share/applications",
+ "/usr/share/applications",
"//usr/share//applications",
)
check = self.check_kls(None)
@@ -42,11 +46,12 @@ class TestInsintoCheck(misc.ReportTestCase):
def test_docinto(self):
check = self.check_kls(None)
- for path in ('${PF}', '${P}', '${PF}/examples'):
+ for path in ("${PF}", "${P}", "${PF}/examples"):
for eapi_str, eapi in EAPI.known_eapis.items():
- fake_src = [f'\tinsinto /usr/share/doc/{path}\n']
+ fake_src = [f"\tinsinto /usr/share/doc/{path}\n"]
fake_pkg = misc.FakePkg(
- "dev-util/diff-0.5", data={'EAPI': eapi_str}, lines=fake_src)
+ "dev-util/diff-0.5", data={"EAPI": eapi_str}, lines=fake_src
+ )
if eapi.options.dodoc_allow_recursive:
r = self.assertReport(check, fake_pkg)
assert path in str(r)
@@ -68,10 +73,10 @@ class TestAbsoluteSymlink(misc.ReportTestCase):
absolute_prefixed = []
for path_var in codingstyle.PATH_VARIABLES:
- src, dest = ('/bin/blah', '/bin/bash')
+ src, dest = ("/bin/blah", "/bin/bash")
absolute_prefixed.append((f'"${{{path_var}}}"{src}', dest))
absolute_prefixed.append((f'"${{{path_var}%/}}"{src}', dest))
- src, dest = ('/bin/blah baz', '/bin/blahbaz')
+ src, dest = ("/bin/blah baz", "/bin/blahbaz")
absolute_prefixed.append((f'"${{{path_var}}}{src}"', dest))
absolute_prefixed.append((f'"${{{path_var}%/}}{src}"', dest))
@@ -99,7 +104,7 @@ class TestAbsoluteSymlink(misc.ReportTestCase):
assert len(reports) == len(absolute) + len(absolute_prefixed)
for r, (src, dest) in zip(reports, absolute + absolute_prefixed):
- assert f'dosym {src}' in str(r)
+ assert f"dosym {src}" in str(r)
class TestPathVariablesCheck(misc.ReportTestCase):
@@ -107,7 +112,7 @@ class TestPathVariablesCheck(misc.ReportTestCase):
check_kls = codingstyle.PathVariablesCheck
check = check_kls(None)
- def _found(self, cls, suffix=''):
+ def _found(self, cls, suffix=""):
# check single and multiple matches across all specified variables
for lines in (1, 2):
for path_var in codingstyle.PATH_VARIABLES:
@@ -117,17 +122,18 @@ class TestPathVariablesCheck(misc.ReportTestCase):
fake_src.extend(["}\n", "\n"])
for eapi_str, eapi in EAPI.known_eapis.items():
fake_pkg = misc.FakePkg(
- "dev-util/diff-0.5", data={'EAPI': eapi_str}, lines=fake_src)
+ "dev-util/diff-0.5", data={"EAPI": eapi_str}, lines=fake_src
+ )
if eapi.options.trailing_slash:
self.assertNoReport(self.check, fake_pkg)
else:
r = self.assertReport(self.check, fake_pkg)
assert isinstance(r, cls)
- assert r.match == f'${{{path_var}{suffix}}}'
+ assert r.match == f"${{{path_var}{suffix}}}"
assert r.lines == tuple(x + 2 for x in range(lines))
assert path_var in str(r)
- def _unfound(self, cls, suffix=''):
+ def _unfound(self, cls, suffix=""):
for path_var in codingstyle.PATH_VARIABLES:
fake_src = [
"src_install() {\n",
@@ -138,7 +144,8 @@ class TestPathVariablesCheck(misc.ReportTestCase):
]
for eapi_str, eapi in EAPI.known_eapis.items():
fake_pkg = misc.FakePkg(
- "dev-util/diffball-0.5", data={'EAPI': eapi_str}, lines=fake_src)
+ "dev-util/diffball-0.5", data={"EAPI": eapi_str}, lines=fake_src
+ )
self.assertNoReport(self.check, fake_pkg)
def test_missing_found(self):
@@ -148,14 +155,14 @@ class TestPathVariablesCheck(misc.ReportTestCase):
self._unfound(codingstyle.MissingSlash)
def test_unnecessary_found(self):
- self._found(codingstyle.UnnecessarySlashStrip, suffix='%/')
+ self._found(codingstyle.UnnecessarySlashStrip, suffix="%/")
def test_unnecessary_unfound(self):
- self._unfound(codingstyle.UnnecessarySlashStrip, suffix='%/')
+ self._unfound(codingstyle.UnnecessarySlashStrip, suffix="%/")
def test_double_prefix_found(self):
fake_src = [
- 'src_install() {\n',
+ "src_install() {\n",
' cp foo.py "${ED}$(python_get_sitedir)"\n',
# test non-match
' cp foo.py "${D%/}$(python_get_sitedir)"\n',
@@ -174,17 +181,17 @@ class TestPathVariablesCheck(misc.ReportTestCase):
' dodir /foo/bar "${EPREFIX}"/bar/baz\n',
# commented lines aren't flagged for double prefix usage
'# exeinto "${EPREFIX}/foo/bar"\n',
- '}\n'
+ "}\n",
]
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
r = self.assertReports(self.check, fake_pkg)
cls = codingstyle.DoublePrefixInPath
expected_results = (
- ('${ED}$(python_get_sitedir)', 2),
- ('${ED%/}$(python_get_sitedir)', 4),
- ('${ED}/$(python_get_sitedir)', 5),
- ('${ED}${PYTHON_SITEDIR}', 6),
- ('${ED}${EPREFIX}', 7),
+ ("${ED}$(python_get_sitedir)", 2),
+ ("${ED%/}$(python_get_sitedir)", 4),
+ ("${ED}/$(python_get_sitedir)", 5),
+ ("${ED}${PYTHON_SITEDIR}", 6),
+ ("${ED}${EPREFIX}", 7),
('insinto "$(python_get_sitedir)', 8),
('exeinto "${EPREFIX}', 9),
('fowners foo:bar "$(python_get_sitedir)', 10),
@@ -199,16 +206,16 @@ class TestPathVariablesCheck(misc.ReportTestCase):
def test_double_prefix_unfound(self):
fake_src = [
- 'src_install() {\n',
+ "src_install() {\n",
' cp foo.py "${D}$(python_get_sitedir)"\n',
' cp foo "${D}${EPREFIX}/foo/bar"\n',
- ' insinto /foo/bar\n',
+ " insinto /foo/bar\n",
# potential false positives: stripping prefix
' insinto "${MYVAR#${EPREFIX}}"\n',
' insinto "${MYVAR#"${EPREFIX}"}"\n',
# combined commands
' dodir /etc/env.d && echo "FOO=${EPREFIX}"\n',
- '}\n'
+ "}\n",
]
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
self.assertNoReport(self.check, fake_pkg)
@@ -219,99 +226,76 @@ class TestObsoleteUri(misc.ReportTestCase):
check_kls = codingstyle.ObsoleteUriCheck
def test_github_archive_uri(self):
- uri = 'https://github.com/foo/bar/archive/${PV}.tar.gz'
- fake_src = [
- f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n'
- ]
+ uri = "https://github.com/foo/bar/archive/${PV}.tar.gz"
+ fake_src = [f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n']
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
self.assertNoReport(self.check_kls(None), fake_pkg)
def test_commented_github_tarball_uri(self):
- uri = 'https://github.com/foo/bar/tarball/${PV}'
- fake_src = [
- '# github tarball\n',
- '\n',
- f'# {uri}\n'
- ]
+ uri = "https://github.com/foo/bar/tarball/${PV}"
+ fake_src = ["# github tarball\n", "\n", f"# {uri}\n"]
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
self.assertNoReport(self.check_kls(None), fake_pkg)
def test_github_tarball_uri(self):
- uri = 'https://github.com/foo/bar/tarball/${PV}'
- fake_src = [
- f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n'
- ]
+ uri = "https://github.com/foo/bar/tarball/${PV}"
+ fake_src = [f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n']
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
r = self.assertReport(self.check_kls(None), fake_pkg)
assert r.line == 1
assert r.uri == uri
- assert (r.replacement ==
- 'https://github.com/foo/bar/archive/${PV}.tar.gz')
+ assert r.replacement == "https://github.com/foo/bar/archive/${PV}.tar.gz"
assert uri in str(r)
def test_github_zipball_uri(self):
- uri = 'https://github.com/foo/bar/zipball/${PV}'
- fake_src = [
- f'SRC_URI="{uri} -> ${{P}}.zip"\n'
- ]
+ uri = "https://github.com/foo/bar/zipball/${PV}"
+ fake_src = [f'SRC_URI="{uri} -> ${{P}}.zip"\n']
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
r = self.assertReport(self.check_kls(None), fake_pkg)
assert r.line == 1
assert r.uri == uri
- assert (r.replacement ==
- 'https://github.com/foo/bar/archive/${PV}.tar.gz')
+ assert r.replacement == "https://github.com/foo/bar/archive/${PV}.tar.gz"
assert uri in str(r)
def test_gitlab_archive_uri(self):
- uri = 'https://gitlab.com/foo/bar/-/archive/${PV}/${P}.tar.gz'
- fake_src = [
- f'SRC_URI="{uri}"\n'
- ]
+ uri = "https://gitlab.com/foo/bar/-/archive/${PV}/${P}.tar.gz"
+ fake_src = [f'SRC_URI="{uri}"\n']
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
self.assertNoReport(self.check_kls(None), fake_pkg)
def test_gitlab_tar_gz_uri(self):
- uri = 'https://gitlab.com/foo/bar/repository/archive.tar.gz?ref=${PV}'
- fake_src = [
- f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n'
- ]
+ uri = "https://gitlab.com/foo/bar/repository/archive.tar.gz?ref=${PV}"
+ fake_src = [f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n']
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
r = self.assertReport(self.check_kls(None), fake_pkg)
assert r.line == 1
assert r.uri == uri
- assert (r.replacement ==
- 'https://gitlab.com/foo/bar/-/archive/${PV}/bar-${PV}.tar.gz')
+ assert r.replacement == "https://gitlab.com/foo/bar/-/archive/${PV}/bar-${PV}.tar.gz"
assert uri in str(r)
def test_gitlab_tar_bz2_uri(self):
- uri = 'https://gitlab.com/foo/bar/repository/archive.tar.bz2?ref=${PV}'
- fake_src = [
- f'SRC_URI="{uri} -> ${{P}}.tar.bz2"\n'
- ]
+ uri = "https://gitlab.com/foo/bar/repository/archive.tar.bz2?ref=${PV}"
+ fake_src = [f'SRC_URI="{uri} -> ${{P}}.tar.bz2"\n']
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
r = self.assertReport(self.check_kls(None), fake_pkg)
assert r.line == 1
assert r.uri == uri
- assert (r.replacement ==
- 'https://gitlab.com/foo/bar/-/archive/${PV}/bar-${PV}.tar.bz2')
+ assert r.replacement == "https://gitlab.com/foo/bar/-/archive/${PV}/bar-${PV}.tar.bz2"
assert uri in str(r)
def test_gitlab_zip_uri(self):
- uri = 'https://gitlab.com/foo/bar/repository/archive.zip?ref=${PV}'
- fake_src = [
- f'SRC_URI="{uri} -> ${{P}}.zip"\n'
- ]
+ uri = "https://gitlab.com/foo/bar/repository/archive.zip?ref=${PV}"
+ fake_src = [f'SRC_URI="{uri} -> ${{P}}.zip"\n']
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
r = self.assertReport(self.check_kls(None), fake_pkg)
assert r.line == 1
assert r.uri == uri
- assert (r.replacement ==
- 'https://gitlab.com/foo/bar/-/archive/${PV}/bar-${PV}.zip')
+ assert r.replacement == "https://gitlab.com/foo/bar/-/archive/${PV}/bar-${PV}.zip"
assert uri in str(r)
@@ -320,15 +304,13 @@ class TestBetterCompression(misc.ReportTestCase):
check_kls = codingstyle.BetterCompressionCheck
def test_github_archive_uri(self):
- uri = 'https://github.com/foo/bar/archive/${PV}.tar.gz'
- fake_src = [
- f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n'
- ]
+ uri = "https://github.com/foo/bar/archive/${PV}.tar.gz"
+ fake_src = [f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n']
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
self.assertNoReport(self.check_kls(None), fake_pkg)
def test_comment_uri(self):
- uri = 'https://gitlab.com/GNOME/${PN}/-/archive/${PV}/${P}.tar'
+ uri = "https://gitlab.com/GNOME/${PN}/-/archive/${PV}/${P}.tar"
fake_src = [
f'#SRC_URI="{uri} -> ${{P}}.tar.gz"\n',
" ",
@@ -339,21 +321,22 @@ class TestBetterCompression(misc.ReportTestCase):
r = self.assertReport(self.check_kls(None), fake_pkg)
assert r.lineno == 4
- @pytest.mark.parametrize('uri', (
- 'https://gitlab.com/GNOME/${PN}/-/archive/${PV}/${P}.tar',
- 'https://gitlab.gnome.org/GNOME/${PN}/-/archive/${PV}/${P}.tar.gz',
- 'https://gitlab.gnome.org/GNOME/${PN}/-/archive/${PV}/${P}.zip',
- 'https://gitlab.freedesktop.org/glvnd/${PN}/-/archive/v${PV}/${PN}-v${PV}.tar.gz',
- ))
+ @pytest.mark.parametrize(
+ "uri",
+ (
+ "https://gitlab.com/GNOME/${PN}/-/archive/${PV}/${P}.tar",
+ "https://gitlab.gnome.org/GNOME/${PN}/-/archive/${PV}/${P}.tar.gz",
+ "https://gitlab.gnome.org/GNOME/${PN}/-/archive/${PV}/${P}.zip",
+ "https://gitlab.freedesktop.org/glvnd/${PN}/-/archive/v${PV}/${PN}-v${PV}.tar.gz",
+ ),
+ )
def test_gitlab_archive_uri(self, uri):
- fake_src = [
- f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n'
- ]
+ fake_src = [f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n']
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
r = self.assertReport(self.check_kls(None), fake_pkg)
assert r.lineno == 1
assert r.line == uri
- assert r.replacement == '.tar.bz2'
+ assert r.replacement == ".tar.bz2"
assert uri in str(r)
@@ -363,76 +346,85 @@ class TestStaticSrcUri(misc.ReportTestCase):
check = check_kls(None)
@staticmethod
- def _prepare_pkg(uri_value: str, rename: str = '', pkgver: str = 'diffball-0.1.2.3'):
+ def _prepare_pkg(uri_value: str, rename: str = "", pkgver: str = "diffball-0.1.2.3"):
if rename:
- rename = f' -> {rename}'
- uri = f'https://github.com/pkgcore/pkgcheck/archive/{uri_value}.tar.gz'
- fake_src = [
- f'SRC_URI="{uri}{rename}"\n'
- ]
+ rename = f" -> {rename}"
+ uri = f"https://github.com/pkgcore/pkgcheck/archive/{uri_value}.tar.gz"
+ fake_src = [f'SRC_URI="{uri}{rename}"\n']
- fake_pkg = misc.FakePkg(f"dev-util/{pkgver}", ebuild=''.join(fake_src), lines=fake_src)
- data = ''.join(fake_src).encode()
+ fake_pkg = misc.FakePkg(f"dev-util/{pkgver}", ebuild="".join(fake_src), lines=fake_src)
+ data = "".join(fake_src).encode()
return _ParsedPkg(data, pkg=fake_pkg)
-
- @pytest.mark.parametrize('value', (
- '${P}',
- '${PV}',
- 'v${PV}',
- 'random-0.1.2.3', # not a valid prefix
- '1.2.3', # currently we support only ver_cut with start=1
- '0', # for ver_cut only if more then 1 part
- ))
+ @pytest.mark.parametrize(
+ "value",
+ (
+ "${P}",
+ "${PV}",
+ "v${PV}",
+ "random-0.1.2.3", # not a valid prefix
+ "1.2.3", # currently we support only ver_cut with start=1
+ "0", # for ver_cut only if more then 1 part
+ ),
+ )
def test_no_report(self, value):
self.assertNoReport(self.check, self._prepare_pkg(value))
- @pytest.mark.parametrize(('value', 'static_str', 'replacement'), (
- ('diffball-0.1.2.3', 'diffball-0.1.2.3', '${P}'),
- ('Diffball-0.1.2.3', 'Diffball-0.1.2.3', '${P^}'),
- ('DIFFBALL-0.1.2.3', 'DIFFBALL-0.1.2.3', '${P^^}'),
- ('diffball-0123', 'diffball-0123', '${P//.}'),
- ('Diffball-0123', 'Diffball-0123', '${P^//.}'),
- ('0.1.2.3', '0.1.2.3', '${PV}'),
- ('v0.1.2.3', '0.1.2.3', '${PV}'),
- ('0.1.2', '0.1.2', '$(ver_cut 1-3)'),
- ('0.1', '0.1', '$(ver_cut 1-2)'),
- ('diffball-0.1.2', '0.1.2', '$(ver_cut 1-3)'),
- ('v0123', '0123', "${PV//.}"),
- ('012.3', '012.3', "$(ver_rs 1-2 '')"),
- ('012.3', '012.3', "$(ver_rs 1-2 '')"),
- ('0_1_2_3', '0_1_2_3', "${PV//./_}"),
- ('0_1_2.3', '0_1_2.3', "$(ver_rs 1-2 '_')"),
- ('0-1.2.3', '0-1.2.3', "$(ver_rs 1 '-')"),
- ))
+ @pytest.mark.parametrize(
+ ("value", "static_str", "replacement"),
+ (
+ ("diffball-0.1.2.3", "diffball-0.1.2.3", "${P}"),
+ ("Diffball-0.1.2.3", "Diffball-0.1.2.3", "${P^}"),
+ ("DIFFBALL-0.1.2.3", "DIFFBALL-0.1.2.3", "${P^^}"),
+ ("diffball-0123", "diffball-0123", "${P//.}"),
+ ("Diffball-0123", "Diffball-0123", "${P^//.}"),
+ ("0.1.2.3", "0.1.2.3", "${PV}"),
+ ("v0.1.2.3", "0.1.2.3", "${PV}"),
+ ("0.1.2", "0.1.2", "$(ver_cut 1-3)"),
+ ("0.1", "0.1", "$(ver_cut 1-2)"),
+ ("diffball-0.1.2", "0.1.2", "$(ver_cut 1-3)"),
+ ("v0123", "0123", "${PV//.}"),
+ ("012.3", "012.3", "$(ver_rs 1-2 '')"),
+ ("012.3", "012.3", "$(ver_rs 1-2 '')"),
+ ("0_1_2_3", "0_1_2_3", "${PV//./_}"),
+ ("0_1_2.3", "0_1_2.3", "$(ver_rs 1-2 '_')"),
+ ("0-1.2.3", "0-1.2.3", "$(ver_rs 1 '-')"),
+ ),
+ )
def test_with_report(self, value, static_str, replacement):
r = self.assertReport(self.check, self._prepare_pkg(value))
assert r.static_str == static_str
assert r.replacement == replacement
def test_rename(self):
- self.assertNoReport(self.check, self._prepare_pkg('${P}', '${P}.tar.gz'))
+ self.assertNoReport(self.check, self._prepare_pkg("${P}", "${P}.tar.gz"))
- r = self.assertReport(self.check, self._prepare_pkg('${P}', 'diffball-0.1.2.3.tar.gz'))
- assert r.static_str == 'diffball-0.1.2.3'
- assert r.replacement == '${P}'
+ r = self.assertReport(self.check, self._prepare_pkg("${P}", "diffball-0.1.2.3.tar.gz"))
+ assert r.static_str == "diffball-0.1.2.3"
+ assert r.replacement == "${P}"
- r = self.assertReport(self.check, self._prepare_pkg('0.1.2.3', '${P}.tar.gz'))
- assert r.static_str == '0.1.2.3'
- assert r.replacement == '${PV}'
+ r = self.assertReport(self.check, self._prepare_pkg("0.1.2.3", "${P}.tar.gz"))
+ assert r.static_str == "0.1.2.3"
+ assert r.replacement == "${PV}"
- r = self.assertReport(self.check, self._prepare_pkg('diffball-0.1.2.3', 'diffball-0.1.2.3.tar.gz'))
- assert r.static_str == 'diffball-0.1.2.3'
- assert r.replacement == '${P}'
+ r = self.assertReport(
+ self.check, self._prepare_pkg("diffball-0.1.2.3", "diffball-0.1.2.3.tar.gz")
+ )
+ assert r.static_str == "diffball-0.1.2.3"
+ assert r.replacement == "${P}"
def test_capitalize(self):
- r = self.assertReport(self.check, self._prepare_pkg('DIFFBALL-0.1.2.3', pkgver='DIFFBALL-0.1.2.3'))
- assert r.static_str == 'DIFFBALL-0.1.2.3'
- assert r.replacement == '${P}'
+ r = self.assertReport(
+ self.check, self._prepare_pkg("DIFFBALL-0.1.2.3", pkgver="DIFFBALL-0.1.2.3")
+ )
+ assert r.static_str == "DIFFBALL-0.1.2.3"
+ assert r.replacement == "${P}"
- r = self.assertReport(self.check, self._prepare_pkg('Diffball-0.1.2.3', pkgver='Diffball-0.1.2.3'))
- assert r.static_str == 'Diffball-0.1.2.3'
- assert r.replacement == '${P}'
+ r = self.assertReport(
+ self.check, self._prepare_pkg("Diffball-0.1.2.3", pkgver="Diffball-0.1.2.3")
+ )
+ assert r.static_str == "Diffball-0.1.2.3"
+ assert r.replacement == "${P}"
class TestExcessiveLineLength(misc.ReportTestCase):
@@ -441,54 +433,68 @@ class TestExcessiveLineLength(misc.ReportTestCase):
check = check_kls(None)
word_length = codingstyle.ExcessiveLineLength.word_length
-
@staticmethod
def _prepare_pkg(*lines: str):
- fake_pkg = misc.FakePkg("dev-util/diffball-0", ebuild=''.join(lines), lines=lines)
- data = ''.join(lines).encode()
+ fake_pkg = misc.FakePkg("dev-util/diffball-0", ebuild="".join(lines), lines=lines)
+ data = "".join(lines).encode()
return _ParsedPkg(data, pkg=fake_pkg)
def test_normal_length(self):
self.assertNoReport(self.check, self._prepare_pkg('echo "short line"'))
def test_long_line(self):
- r = self.assertReport(self.check, self._prepare_pkg(f'echo {"a " * codingstyle.ExcessiveLineLength.line_length}'))
- assert r.lines == (1, )
+ r = self.assertReport(
+ self.check,
+ self._prepare_pkg(f'echo {"a " * codingstyle.ExcessiveLineLength.line_length}'),
+ )
+ assert r.lines == (1,)
def test_multiple_lines(self):
- r = self.assertReport(self.check, self._prepare_pkg(
- f'echo {"a " * codingstyle.ExcessiveLineLength.line_length}',
- 'echo "short line"',
- f'echo {"Hello " * codingstyle.ExcessiveLineLength.line_length}',
- ))
+ r = self.assertReport(
+ self.check,
+ self._prepare_pkg(
+ f'echo {"a " * codingstyle.ExcessiveLineLength.line_length}',
+ 'echo "short line"',
+ f'echo {"Hello " * codingstyle.ExcessiveLineLength.line_length}',
+ ),
+ )
assert r.lines == (1, 3)
- @pytest.mark.parametrize('variable', ('DESCRIPTION', 'KEYWORDS', 'IUSE'))
+ @pytest.mark.parametrize("variable", ("DESCRIPTION", "KEYWORDS", "IUSE"))
def test_special_variables(self, variable):
- self.assertNoReport(self.check, self._prepare_pkg(
- f'{variable}="{"a " * codingstyle.ExcessiveLineLength.line_length}"',
- f' {variable}="{"a " * codingstyle.ExcessiveLineLength.line_length}"',
- f'\t\t{variable}="{"a " * codingstyle.ExcessiveLineLength.line_length}"',
- ))
+ self.assertNoReport(
+ self.check,
+ self._prepare_pkg(
+ f'{variable}="{"a " * codingstyle.ExcessiveLineLength.line_length}"',
+ f' {variable}="{"a " * codingstyle.ExcessiveLineLength.line_length}"',
+ f'\t\t{variable}="{"a " * codingstyle.ExcessiveLineLength.line_length}"',
+ ),
+ )
def test_long_words(self):
- long_word = 'a' * self.word_length + 'b'
- medium_word = 'a' * (self.word_length // 2)
- r = self.assertReport(self.check, self._prepare_pkg(
- f'echo {"a" * codingstyle.ExcessiveLineLength.line_length}',
- f'echo {medium_word} {long_word}',
- f'echo {medium_word} {long_word[:-5]}',
- ))
- assert r.lines == (3, )
+ long_word = "a" * self.word_length + "b"
+ medium_word = "a" * (self.word_length // 2)
+ r = self.assertReport(
+ self.check,
+ self._prepare_pkg(
+ f'echo {"a" * codingstyle.ExcessiveLineLength.line_length}',
+ f"echo {medium_word} {long_word}",
+ f"echo {medium_word} {long_word[:-5]}",
+ ),
+ )
+ assert r.lines == (3,)
def test_long_quotes(self):
# The exception is for any quoted string with length >= word_length.
# Each quoted string is computed by itself.
- long_word = 'a ' * (self.word_length // 2) + 'b' # long quoted string, skipped
- medium_word = 'a ' * (self.word_length // 4) # not long enough string, not skipped
- r = self.assertReport(self.check, self._prepare_pkg(
- f'echo "{"a" * codingstyle.ExcessiveLineLength.line_length}"',
- f'echo "{medium_word}" "{long_word}"',
- 'echo' + f' "{medium_word}"' * 3,
- ))
- assert r.lines == (3, )
+ long_word = "a " * (self.word_length // 2) + "b" # long quoted string, skipped
+ medium_word = "a " * (self.word_length // 4) # not long enough string, not skipped
+ r = self.assertReport(
+ self.check,
+ self._prepare_pkg(
+ f'echo "{"a" * codingstyle.ExcessiveLineLength.line_length}"',
+ f'echo "{medium_word}" "{long_word}"',
+ "echo" + f' "{medium_word}"' * 3,
+ ),
+ )
+ assert r.lines == (3,)
diff --git a/tests/checks/test_dropped_keywords.py b/tests/checks/test_dropped_keywords.py
index 6b070919..fbfee5fc 100644
--- a/tests/checks/test_dropped_keywords.py
+++ b/tests/checks/test_dropped_keywords.py
@@ -8,65 +8,62 @@ class TestDroppedKeywords(misc.ReportTestCase):
check_kls = dropped_keywords.DroppedKeywordsCheck
- def mk_pkg(self, ver, keywords='', eclasses=(), **kwargs):
+ def mk_pkg(self, ver, keywords="", eclasses=(), **kwargs):
return misc.FakePkg(
f"dev-util/diffball-{ver}",
data={
**kwargs,
"KEYWORDS": keywords,
"_eclasses_": eclasses,
- })
+ },
+ )
- def mk_check(self, arches=('x86', 'amd64'), verbosity=0):
+ def mk_check(self, arches=("x86", "amd64"), verbosity=0):
options = arghparse.Namespace(arches=arches, verbosity=verbosity)
return self.check_kls(options, arches_addon=None)
def test_it(self):
# single version, shouldn't yield.
check = self.mk_check()
- self.assertNoReport(check, [self.mk_pkg('1')])
+ self.assertNoReport(check, [self.mk_pkg("1")])
# ebuilds without keywords are skipped
- self.assertNoReport(
- check, [self.mk_pkg("1", "x86 amd64"), self.mk_pkg("2")])
+ self.assertNoReport(check, [self.mk_pkg("1", "x86 amd64"), self.mk_pkg("2")])
# ensure it limits itself to just the arches we care about
# check unstable at the same time;
# finally, check '-' handling; if x86 -> -x86, that's valid.
self.assertNoReport(
check,
- [self.mk_pkg("1", "x86 ~amd64 ppc"),
- self.mk_pkg("2", "~amd64 x86"),
- self.mk_pkg("3", "-amd64 x86")])
+ [
+ self.mk_pkg("1", "x86 ~amd64 ppc"),
+ self.mk_pkg("2", "~amd64 x86"),
+ self.mk_pkg("3", "-amd64 x86"),
+ ],
+ )
# check added keyword handling
self.assertNoReport(
check,
- [self.mk_pkg("1", "amd64"),
- self.mk_pkg("2", "x86"),
- self.mk_pkg("3", "~x86 ~amd64")])
+ [self.mk_pkg("1", "amd64"), self.mk_pkg("2", "x86"), self.mk_pkg("3", "~x86 ~amd64")],
+ )
# check special keyword handling
- for key in ('-*', '*', '~*'):
- self.assertNoReport(
- check,
- [self.mk_pkg("1", "x86 ~amd64"),
- self.mk_pkg("2", key)])
+ for key in ("-*", "*", "~*"):
+ self.assertNoReport(check, [self.mk_pkg("1", "x86 ~amd64"), self.mk_pkg("2", key)])
# ensure it doesn't flag live ebuilds
self.assertNoReport(
- check,
- [self.mk_pkg("1", "x86 amd64"),
- self.mk_pkg("9999", "", PROPERTIES='live')])
+ check, [self.mk_pkg("1", "x86 amd64"), self.mk_pkg("9999", "", PROPERTIES="live")]
+ )
def test_verbose_mode(self):
# verbose mode outputs a report per version with dropped keywords
check = self.mk_check(verbosity=1)
reports = self.assertReports(
check,
- [self.mk_pkg("1", "amd64 x86"),
- self.mk_pkg("2", "amd64"),
- self.mk_pkg("3", "amd64")])
+ [self.mk_pkg("1", "amd64 x86"), self.mk_pkg("2", "amd64"), self.mk_pkg("3", "amd64")],
+ )
assert len(reports) == 2
assert {x.version for x in reports} == {"2", "3"}
assert set().union(*(x.arches for x in reports)) == {"x86"}
@@ -76,9 +73,8 @@ class TestDroppedKeywords(misc.ReportTestCase):
check = self.mk_check()
reports = self.assertReports(
check,
- [self.mk_pkg("1", "x86 amd64"),
- self.mk_pkg("2", "amd64"),
- self.mk_pkg("3", "amd64")])
+ [self.mk_pkg("1", "x86 amd64"), self.mk_pkg("2", "amd64"), self.mk_pkg("3", "amd64")],
+ )
assert len(reports) == 1
- assert reports[0].version == '3'
+ assert reports[0].version == "3"
assert set().union(*(x.arches for x in reports)) == {"x86"}
diff --git a/tests/checks/test_git.py b/tests/checks/test_git.py
index 150d8b8b..1cefd549 100644
--- a/tests/checks/test_git.py
+++ b/tests/checks/test_git.py
@@ -21,11 +21,11 @@ class FakeCommit(GitCommit):
def __init__(self, **kwargs):
commit_data = {
- 'hash': '7f9abd7ec2d079b1d0c36fc2f5d626ae0691757e',
- 'commit_time': 1613438722,
- 'author': 'author@domain.com',
- 'committer': 'author@domain.com',
- 'message': (),
+ "hash": "7f9abd7ec2d079b1d0c36fc2f5d626ae0691757e",
+ "commit_time": 1613438722,
+ "author": "author@domain.com",
+ "committer": "author@domain.com",
+ "message": (),
}
commit_data.update(kwargs)
super().__init__(**commit_data)
@@ -33,199 +33,217 @@ class FakeCommit(GitCommit):
class TestGitCommitMessageCheck(ReportTestCase):
check_kls = git_mod.GitCommitMessageCheck
- options = arghparse.Namespace(
- target_repo=FakeRepo(), commits='origin', gentoo_repo=True)
+ options = arghparse.Namespace(target_repo=FakeRepo(), commits="origin", gentoo_repo=True)
check = git_mod.GitCommitMessageCheck(options)
def test_sign_offs(self):
# assert that it checks for both author and comitter
r = self.assertReport(
- self.check,
- FakeCommit(author='user1', committer='user2', message=['blah'])
+ self.check, FakeCommit(author="user1", committer="user2", message=["blah"])
)
assert isinstance(r, git_mod.MissingSignOff)
- assert r.missing_sign_offs == ('user1', 'user2')
+ assert r.missing_sign_offs == ("user1", "user2")
# assert that it handles author/committer being the same
self.assertNoReport(
self.check,
FakeCommit(
- author='user@user.com', committer='user@user.com',
- message=['summary', '', 'Signed-off-by: user@user.com']))
+ author="user@user.com",
+ committer="user@user.com",
+ message=["summary", "", "Signed-off-by: user@user.com"],
+ ),
+ )
# assert it can handle multiple sign offs.
self.assertNoReport(
self.check,
FakeCommit(
- author='user1', committer='user2',
- message=['summary', '', 'Signed-off-by: user2', 'Signed-off-by: user1']))
+ author="user1",
+ committer="user2",
+ message=["summary", "", "Signed-off-by: user2", "Signed-off-by: user1"],
+ ),
+ )
- def SO_commit(self, summary='summary', body='', tags=(), **kwargs):
+ def SO_commit(self, summary="summary", body="", tags=(), **kwargs):
"""Create a commit object from summary, body, and tags components."""
- author = kwargs.pop('author', 'author@domain.com')
- committer = kwargs.pop('committer', 'author@domain.com')
+ author = kwargs.pop("author", "author@domain.com")
+ committer = kwargs.pop("committer", "author@domain.com")
message = summary
if message:
if body:
- message += '\n\n' + body
- sign_offs = tuple(f'Signed-off-by: {user}' for user in {author, committer})
- message += '\n\n' + '\n'.join(tuple(tags) + sign_offs)
+ message += "\n\n" + body
+ sign_offs = tuple(f"Signed-off-by: {user}" for user in {author, committer})
+ message += "\n\n" + "\n".join(tuple(tags) + sign_offs)
return FakeCommit(author=author, committer=committer, message=message.splitlines())
def test_invalid_commit_tag(self):
# assert it doesn't puke if there are no tags
self.assertNoReport(self.check, self.SO_commit())
- self.assertNoReport(self.check, self.SO_commit(tags=['Bug: https://gentoo.org/blah']))
- self.assertNoReport(self.check, self.SO_commit(tags=['Close: https://gentoo.org/blah']))
+ self.assertNoReport(self.check, self.SO_commit(tags=["Bug: https://gentoo.org/blah"]))
+ self.assertNoReport(self.check, self.SO_commit(tags=["Close: https://gentoo.org/blah"]))
- r = self.assertReport(self.check, self.SO_commit(tags=['Bug: 123455']))
+ r = self.assertReport(self.check, self.SO_commit(tags=["Bug: 123455"]))
assert isinstance(r, git_mod.InvalidCommitTag)
- assert (r.tag, r.value, r.error) == ('Bug', '123455', "value isn't a URL")
+ assert (r.tag, r.value, r.error) == ("Bug", "123455", "value isn't a URL")
# Do a protocol check; this is more of an assertion against the parsing model
# used in the implementation.
- r = self.assertReport(self.check, self.SO_commit(tags=['Closes: ftp://blah.com/asdf']))
+ r = self.assertReport(self.check, self.SO_commit(tags=["Closes: ftp://blah.com/asdf"]))
assert isinstance(r, git_mod.InvalidCommitTag)
- assert r.tag == 'Closes'
- assert 'protocol' in r.error
+ assert r.tag == "Closes"
+ assert "protocol" in r.error
def test_gentoo_bug_tag(self):
- commit = self.SO_commit(tags=['Gentoo-Bug: https://bugs.gentoo.org/1'])
- assert 'Gentoo-Bug tag is no longer valid' in self.assertReport(self.check, commit).error
+ commit = self.SO_commit(tags=["Gentoo-Bug: https://bugs.gentoo.org/1"])
+ assert "Gentoo-Bug tag is no longer valid" in self.assertReport(self.check, commit).error
def test_commit_tags(self):
- ref = 'd8337304f09'
+ ref = "d8337304f09"
- for tag in ('Fixes', 'Reverts'):
+ for tag in ("Fixes", "Reverts"):
# no results on `git cat-file` failure
- with patch('pkgcheck.checks.git.subprocess.Popen') as git_cat:
+ with patch("pkgcheck.checks.git.subprocess.Popen") as git_cat:
# force using a new `git cat-file` process for each iteration
self.check._git_cat_file = None
git_cat.return_value.poll.return_value = -1
- commit = self.SO_commit(tags=[f'{tag}: {ref}'])
+ commit = self.SO_commit(tags=[f"{tag}: {ref}"])
self.assertNoReport(self.check, commit)
# missing and ambiguous object refs
- for status in ('missing', 'ambiguous'):
+ for status in ("missing", "ambiguous"):
self.check._git_cat_file = None
- with patch('pkgcheck.checks.git.subprocess.Popen') as git_cat:
+ with patch("pkgcheck.checks.git.subprocess.Popen") as git_cat:
git_cat.return_value.poll.return_value = None
- git_cat.return_value.stdout.readline.return_value = f'{ref} {status}'
- commit = self.SO_commit(tags=[f'{tag}: {ref}'])
+ git_cat.return_value.stdout.readline.return_value = f"{ref} {status}"
+ commit = self.SO_commit(tags=[f"{tag}: {ref}"])
r = self.assertReport(self.check, commit)
assert isinstance(r, git_mod.InvalidCommitTag)
- assert f'{status} commit' in r.error
+ assert f"{status} commit" in r.error
# valid tag reference
- with patch('pkgcheck.checks.git.subprocess.Popen') as git_cat:
+ with patch("pkgcheck.checks.git.subprocess.Popen") as git_cat:
self.check._git_cat_file = None
git_cat.return_value.poll.return_value = None
- git_cat.return_value.stdout.readline.return_value = f'{ref} commit 1234'
- commit = self.SO_commit(tags=[f'{tag}: {ref}'])
+ git_cat.return_value.stdout.readline.return_value = f"{ref} commit 1234"
+ commit = self.SO_commit(tags=[f"{tag}: {ref}"])
self.assertNoReport(self.check, commit)
def test_summary_length(self):
- self.assertNoReport(self.check, self.SO_commit('single summary headline'))
- self.assertNoReport(self.check, self.SO_commit('a' * 69))
- assert 'no commit message' in \
- self.assertReport(self.check, self.SO_commit('')).error
- assert 'summary is too long' in \
- self.assertReport(self.check, self.SO_commit('a' * 70)).error
+ self.assertNoReport(self.check, self.SO_commit("single summary headline"))
+ self.assertNoReport(self.check, self.SO_commit("a" * 69))
+ assert "no commit message" in self.assertReport(self.check, self.SO_commit("")).error
+ assert (
+ "summary is too long" in self.assertReport(self.check, self.SO_commit("a" * 70)).error
+ )
def test_message_body_length(self):
# message body lines longer than 80 chars are flagged
- long_line = 'a' + ' b' * 40
- assert 'line 2 greater than 80 chars' in \
- self.assertReport(
- self.check,
- self.SO_commit(body=long_line)).error
+ long_line = "a" + " b" * 40
+ assert (
+ "line 2 greater than 80 chars"
+ in self.assertReport(self.check, self.SO_commit(body=long_line)).error
+ )
# but not non-word lines
- long_line = 'a' * 81
+ long_line = "a" * 81
self.assertNoReport(self.check, self.SO_commit(body=long_line))
def test_message_empty_lines(self):
- message = textwrap.dedent("""\
- foo
+ message = textwrap.dedent(
+ """\
+ foo
- bar
+ bar
- Signed-off-by: author@domain.com
- """).splitlines()
+ Signed-off-by: author@domain.com
+ """
+ ).splitlines()
commit = FakeCommit(message=message)
self.assertNoReport(self.check, commit)
# missing empty line between summary and body
- message = textwrap.dedent("""\
- foo
- bar
+ message = textwrap.dedent(
+ """\
+ foo
+ bar
- Signed-off-by: author@domain.com
- """).splitlines()
+ Signed-off-by: author@domain.com
+ """
+ ).splitlines()
commit = FakeCommit(message=message)
r = self.assertReport(self.check, commit)
- assert 'missing empty line before body' in str(r)
+ assert "missing empty line before body" in str(r)
# missing empty line between summary and tags
- message = textwrap.dedent("""\
- foo
- Signed-off-by: author@domain.com
- """).splitlines()
+ message = textwrap.dedent(
+ """\
+ foo
+ Signed-off-by: author@domain.com
+ """
+ ).splitlines()
commit = FakeCommit(message=message)
r = self.assertReport(self.check, commit)
- assert 'missing empty line before tags' in str(r)
+ assert "missing empty line before tags" in str(r)
# missing empty lines between summary, body, and tags
- message = textwrap.dedent("""\
- foo
- bar
- Signed-off-by: author@domain.com
- """).splitlines()
+ message = textwrap.dedent(
+ """\
+ foo
+ bar
+ Signed-off-by: author@domain.com
+ """
+ ).splitlines()
commit = FakeCommit(message=message)
reports = self.assertReports(self.check, commit)
- assert 'missing empty line before body' in str(reports[0])
- assert 'missing empty line before tags' in str(reports[1])
+ assert "missing empty line before body" in str(reports[0])
+ assert "missing empty line before tags" in str(reports[1])
def test_footer_empty_lines(self):
- for whitespace in ('\t', ' ', ''):
+ for whitespace in ("\t", " ", ""):
# empty lines in footer are flagged
- message = textwrap.dedent(f"""\
- foon
-
- blah: dar
- {whitespace}
- footer: yep
- Signed-off-by: author@domain.com
- """).splitlines()
+ message = textwrap.dedent(
+ f"""\
+ foon
+
+ blah: dar
+ {whitespace}
+ footer: yep
+ Signed-off-by: author@domain.com
+ """
+ ).splitlines()
commit = FakeCommit(message=message)
r = self.assertReport(self.check, commit)
- assert 'empty line 4 in footer' in str(r)
+ assert "empty line 4 in footer" in str(r)
# empty lines at the end of a commit message are ignored
- message = textwrap.dedent(f"""\
+ message = textwrap.dedent(
+ f"""\
+ foon
+
+ blah: dar
+ footer: yep
+ Signed-off-by: author@domain.com
+ {whitespace}
+ """
+ ).splitlines()
+ commit = FakeCommit(message=message)
+ self.assertNoReport(self.check, commit)
+
+ def test_footer_non_tags(self):
+ message = textwrap.dedent(
+ """\
foon
blah: dar
footer: yep
+ some random line
Signed-off-by: author@domain.com
- {whitespace}
- """).splitlines()
- commit = FakeCommit(message=message)
- self.assertNoReport(self.check, commit)
-
- def test_footer_non_tags(self):
- message = textwrap.dedent("""\
- foon
-
- blah: dar
- footer: yep
- some random line
- Signed-off-by: author@domain.com
- """).splitlines()
+ """
+ ).splitlines()
commit = FakeCommit(message=message)
r = self.assertReport(self.check, commit)
- assert 'non-tag in footer, line 5' in str(r)
+ assert "non-tag in footer, line 5" in str(r)
class TestGitCommitMessageRepoCheck(ReportTestCase):
@@ -239,18 +257,17 @@ class TestGitCommitMessageRepoCheck(ReportTestCase):
# initialize parent repo
self.parent_git_repo = make_git_repo()
- self.parent_repo = make_repo(
- self.parent_git_repo.path, repo_id='gentoo', arches=['amd64'])
- self.parent_git_repo.add_all('initial commit')
+ self.parent_repo = make_repo(self.parent_git_repo.path, repo_id="gentoo", arches=["amd64"])
+ self.parent_git_repo.add_all("initial commit")
# create a stub pkg and commit it
- self.parent_repo.create_ebuild('cat/pkg-0')
- self.parent_git_repo.add_all('cat/pkg-0')
+ self.parent_repo.create_ebuild("cat/pkg-0")
+ self.parent_git_repo.add_all("cat/pkg-0")
# initialize child repo
self.child_git_repo = make_git_repo()
- self.child_git_repo.run(['git', 'remote', 'add', 'origin', self.parent_git_repo.path])
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_git_repo.run(['git', 'remote', 'set-head', 'origin', 'main'])
+ self.child_git_repo.run(["git", "remote", "add", "origin", self.parent_git_repo.path])
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_git_repo.run(["git", "remote", "set-head", "origin", "main"])
self.child_repo = make_repo(self.child_git_repo.path)
def init_check(self, options=None, future=0):
@@ -263,96 +280,106 @@ class TestGitCommitMessageRepoCheck(ReportTestCase):
def _options(self, **kwargs):
args = [
- 'scan', '-q', '--cache-dir', self.cache_dir,
- '--repo', self.child_repo.location, '--commits',
+ "scan",
+ "-q",
+ "--cache-dir",
+ self.cache_dir,
+ "--repo",
+ self.child_repo.location,
+ "--commits",
]
options, _ = self._tool.parse_args(args)
return options
def test_bad_commit_summary_pkg(self):
# properly prefixed commit summary
- self.child_repo.create_ebuild('cat/pkg-1')
- self.child_git_repo.add_all('cat/pkg: version bump to 1', signoff=True)
+ self.child_repo.create_ebuild("cat/pkg-1")
+ self.child_git_repo.add_all("cat/pkg: version bump to 1", signoff=True)
self.init_check()
self.assertNoReport(self.check, self.source)
# properly prefixed multiple ebuild commit summary
- self.child_repo.create_ebuild('cat/pkg-2')
- self.child_repo.create_ebuild('cat/pkg-3')
- self.child_git_repo.add_all('cat/pkg: more version bumps', signoff=True)
+ self.child_repo.create_ebuild("cat/pkg-2")
+ self.child_repo.create_ebuild("cat/pkg-3")
+ self.child_git_repo.add_all("cat/pkg: more version bumps", signoff=True)
self.init_check()
self.assertNoReport(self.check, self.source)
# special categories that allow not having version in new package summary
- self.child_repo.create_ebuild('acct-user/pkgcheck-1')
- self.child_git_repo.add_all('acct-user/pkgcheck: add user for pkgcheck', signoff=True)
+ self.child_repo.create_ebuild("acct-user/pkgcheck-1")
+ self.child_git_repo.add_all("acct-user/pkgcheck: add user for pkgcheck", signoff=True)
self.init_check()
self.assertNoReport(self.check, self.source)
# special categories that allow not having version in bump version summary
- self.child_repo.create_ebuild('acct-user/pkgcheck-2')
- self.child_git_repo.add_all('acct-user/pkgcheck: bump user for pkgcheck', signoff=True)
+ self.child_repo.create_ebuild("acct-user/pkgcheck-2")
+ self.child_git_repo.add_all("acct-user/pkgcheck: bump user for pkgcheck", signoff=True)
self.init_check()
self.assertNoReport(self.check, self.source)
# poorly prefixed commit summary
- self.child_repo.create_ebuild('cat/pkg-4')
- self.child_git_repo.add_all('version bump to 4', signoff=True)
+ self.child_repo.create_ebuild("cat/pkg-4")
+ self.child_git_repo.add_all("version bump to 4", signoff=True)
commit1 = self.child_git_repo.HEAD
# commit summary missing package version
- self.child_repo.create_ebuild('cat/pkg-5')
- self.child_git_repo.add_all('cat/pkg: version bump', signoff=True)
+ self.child_repo.create_ebuild("cat/pkg-5")
+ self.child_git_repo.add_all("cat/pkg: version bump", signoff=True)
commit2 = self.child_git_repo.HEAD
# commit summary missing renamed package version
self.child_git_repo.move(
- 'cat/pkg/pkg-3.ebuild', 'cat/pkg/pkg-6.ebuild',
- msg='cat/pkg: version bump and remove old', signoff=True)
+ "cat/pkg/pkg-3.ebuild",
+ "cat/pkg/pkg-6.ebuild",
+ msg="cat/pkg: version bump and remove old",
+ signoff=True,
+ )
commit3 = self.child_git_repo.HEAD
# revision bumps aren't flagged
- self.child_repo.create_ebuild('cat/pkg-6-r1')
- self.child_git_repo.add_all('cat/pkg: revision bump', signoff=True)
+ self.child_repo.create_ebuild("cat/pkg-6-r1")
+ self.child_git_repo.add_all("cat/pkg: revision bump", signoff=True)
self.init_check()
# allow vVERSION
- self.child_repo.create_ebuild('cat/pkg-7')
- self.child_git_repo.add_all('cat/pkg: bump to v7', signoff=True)
+ self.child_repo.create_ebuild("cat/pkg-7")
+ self.child_git_repo.add_all("cat/pkg: bump to v7", signoff=True)
self.init_check()
results = self.assertReports(self.check, self.source)
r1 = git_mod.BadCommitSummary(
- "summary missing 'cat/pkg' package prefix",
- 'version bump to 4', commit=commit1)
+ "summary missing 'cat/pkg' package prefix", "version bump to 4", commit=commit1
+ )
r2 = git_mod.BadCommitSummary(
- "summary missing package version '5'",
- 'cat/pkg: version bump', commit=commit2)
+ "summary missing package version '5'", "cat/pkg: version bump", commit=commit2
+ )
r3 = git_mod.BadCommitSummary(
"summary missing package version '6'",
- 'cat/pkg: version bump and remove old', commit=commit3)
+ "cat/pkg: version bump and remove old",
+ commit=commit3,
+ )
assert set(results) == {r1, r2, r3}
def test_bad_commit_summary_category(self):
# properly prefixed commit summary
- self.child_repo.create_ebuild('cat/pkg1-1')
- self.child_repo.create_ebuild('cat/pkg2-1')
- self.child_git_repo.add_all('cat: various pkg updates', signoff=True)
+ self.child_repo.create_ebuild("cat/pkg1-1")
+ self.child_repo.create_ebuild("cat/pkg2-1")
+ self.child_git_repo.add_all("cat: various pkg updates", signoff=True)
self.init_check()
self.assertNoReport(self.check, self.source)
# multiple category commits are ignored
- self.child_repo.create_ebuild('newcat1/newcat1-1')
- self.child_repo.create_ebuild('newcat2/newpkg2-1')
- self.child_git_repo.add_all('various changes', signoff=True)
+ self.child_repo.create_ebuild("newcat1/newcat1-1")
+ self.child_repo.create_ebuild("newcat2/newpkg2-1")
+ self.child_git_repo.add_all("various changes", signoff=True)
self.init_check()
self.assertNoReport(self.check, self.source)
# poorly prefixed commit summary for single category changes
- self.child_repo.create_ebuild('cat/pkg3-1')
- self.child_repo.create_ebuild('cat/pkg4-1')
- self.child_git_repo.add_all('cat updates', signoff=True)
+ self.child_repo.create_ebuild("cat/pkg3-1")
+ self.child_repo.create_ebuild("cat/pkg4-1")
+ self.child_git_repo.add_all("cat updates", signoff=True)
commit = self.child_git_repo.HEAD
self.init_check()
r = self.assertReport(self.check, self.source)
expected = git_mod.BadCommitSummary(
- "summary missing 'cat' category prefix",
- 'cat updates', commit=commit)
+ "summary missing 'cat' category prefix", "cat updates", commit=commit
+ )
assert r == expected
@@ -367,18 +394,17 @@ class TestGitPkgCommitsCheck(ReportTestCase):
# initialize parent repo
self.parent_git_repo = make_git_repo()
- self.parent_repo = make_repo(
- self.parent_git_repo.path, repo_id='gentoo', arches=['amd64'])
- self.parent_git_repo.add_all('initial commit')
+ self.parent_repo = make_repo(self.parent_git_repo.path, repo_id="gentoo", arches=["amd64"])
+ self.parent_git_repo.add_all("initial commit")
# create a stub pkg and commit it
- self.parent_repo.create_ebuild('cat/pkg-0')
- self.parent_git_repo.add_all('cat/pkg-0')
+ self.parent_repo.create_ebuild("cat/pkg-0")
+ self.parent_git_repo.add_all("cat/pkg-0")
# initialize child repo
self.child_git_repo = make_git_repo()
- self.child_git_repo.run(['git', 'remote', 'add', 'origin', self.parent_git_repo.path])
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_git_repo.run(['git', 'remote', 'set-head', 'origin', 'main'])
+ self.child_git_repo.run(["git", "remote", "add", "origin", self.parent_git_repo.path])
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_git_repo.run(["git", "remote", "set-head", "origin", "main"])
self.child_repo = make_repo(self.child_git_repo.path)
def init_check(self, options=None, future=0):
@@ -391,193 +417,206 @@ class TestGitPkgCommitsCheck(ReportTestCase):
def _options(self, **kwargs):
args = [
- 'scan', '-q', '--cache-dir', self.cache_dir,
- '--repo', self.child_repo.location, '--commits',
+ "scan",
+ "-q",
+ "--cache-dir",
+ self.cache_dir,
+ "--repo",
+ self.child_repo.location,
+ "--commits",
]
options, _ = self._tool.parse_args(args)
return options
def test_broken_ebuilds_ignored(self):
- self.child_repo.create_ebuild('newcat/pkg-1', eapi='-1')
- self.child_git_repo.add_all('newcat/pkg: initial import')
+ self.child_repo.create_ebuild("newcat/pkg-1", eapi="-1")
+ self.child_git_repo.add_all("newcat/pkg: initial import")
self.init_check()
self.assertNoReport(self.check, self.source)
def test_direct_stable(self):
- self.child_repo.create_ebuild('cat/pkg-1', keywords=['amd64'])
- self.child_git_repo.add_all('cat/pkg: version bump to 1')
+ self.child_repo.create_ebuild("cat/pkg-1", keywords=["amd64"])
+ self.child_git_repo.add_all("cat/pkg: version bump to 1")
self.init_check()
r = self.assertReport(self.check, self.source)
- expected = git_mod.DirectStableKeywords(['amd64'], pkg=CPV('cat/pkg-1'))
+ expected = git_mod.DirectStableKeywords(["amd64"], pkg=CPV("cat/pkg-1"))
assert r == expected
def test_direct_no_maintainer(self):
- self.child_repo.create_ebuild('newcat/pkg-1')
- self.child_git_repo.add_all('newcat/pkg: initial import')
+ self.child_repo.create_ebuild("newcat/pkg-1")
+ self.child_git_repo.add_all("newcat/pkg: initial import")
self.init_check()
r = self.assertReport(self.check, self.source)
- expected = git_mod.DirectNoMaintainer(pkg=CPV('newcat/pkg-1'))
+ expected = git_mod.DirectNoMaintainer(pkg=CPV("newcat/pkg-1"))
assert r == expected
def test_ebuild_incorrect_copyright(self):
- self.child_repo.create_ebuild('cat/pkg-1')
- line = '# Copyright 1999-2019 Gentoo Authors'
- with open(pjoin(self.child_git_repo.path, 'cat/pkg/pkg-1.ebuild'), 'r+') as f:
+ self.child_repo.create_ebuild("cat/pkg-1")
+ line = "# Copyright 1999-2019 Gentoo Authors"
+ with open(pjoin(self.child_git_repo.path, "cat/pkg/pkg-1.ebuild"), "r+") as f:
lines = f.read().splitlines()
lines[0] = line
f.seek(0)
f.truncate()
- f.write('\n'.join(lines))
- self.child_git_repo.add_all('cat/pkg: version bump to 1')
+ f.write("\n".join(lines))
+ self.child_git_repo.add_all("cat/pkg: version bump to 1")
self.init_check()
r = self.assertReport(self.check, self.source)
- expected = git_mod.EbuildIncorrectCopyright('2019', line=line, pkg=CPV('cat/pkg-1'))
+ expected = git_mod.EbuildIncorrectCopyright("2019", line=line, pkg=CPV("cat/pkg-1"))
assert r == expected
def test_missing_copyright(self):
"""Ebuilds missing copyrights entirely are handled by EbuildHeaderCheck."""
- self.child_repo.create_ebuild('cat/pkg-1')
- with open(pjoin(self.child_git_repo.path, 'cat/pkg/pkg-1.ebuild'), 'r+') as f:
+ self.child_repo.create_ebuild("cat/pkg-1")
+ with open(pjoin(self.child_git_repo.path, "cat/pkg/pkg-1.ebuild"), "r+") as f:
lines = f.read().splitlines()
f.seek(0)
f.truncate()
- f.write('\n'.join(lines[1:]))
- self.child_git_repo.add_all('cat/pkg: update ebuild')
+ f.write("\n".join(lines[1:]))
+ self.child_git_repo.add_all("cat/pkg: update ebuild")
self.init_check()
self.assertNoReport(self.check, self.source)
def test_dropped_stable_keywords(self):
# add stable ebuild to parent repo
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['amd64'])
- self.parent_git_repo.add_all('cat/pkg: version bump to 1')
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["amd64"])
+ self.parent_git_repo.add_all("cat/pkg: version bump to 1")
# pull changes and remove it from the child repo
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_git_repo.remove('cat/pkg/pkg-1.ebuild', msg='cat/pkg: remove 1')
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_git_repo.remove("cat/pkg/pkg-1.ebuild", msg="cat/pkg: remove 1")
commit = self.child_git_repo.HEAD
self.init_check()
r = self.assertReport(self.check, self.source)
- expected = git_mod.DroppedStableKeywords(['amd64'], commit, pkg=CPV('cat/pkg-1'))
+ expected = git_mod.DroppedStableKeywords(["amd64"], commit, pkg=CPV("cat/pkg-1"))
assert r == expected
# git archive failures error out
- with patch('pkgcheck.checks.git.subprocess.Popen') as git_archive:
+ with patch("pkgcheck.checks.git.subprocess.Popen") as git_archive:
git_archive.return_value.poll.return_value = -1
- with pytest.raises(PkgcheckUserException, match='failed populating archive repo'):
+ with pytest.raises(PkgcheckUserException, match="failed populating archive repo"):
self.assertNoReport(self.check, self.source)
def test_dropped_unstable_keywords(self):
# add stable ebuild to parent repo
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['~amd64'])
- self.parent_git_repo.add_all('cat/pkg: version bump to 1')
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["~amd64"])
+ self.parent_git_repo.add_all("cat/pkg: version bump to 1")
# pull changes and remove it from the child repo
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_git_repo.remove('cat/pkg/pkg-1.ebuild', msg='cat/pkg: remove 1')
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_git_repo.remove("cat/pkg/pkg-1.ebuild", msg="cat/pkg: remove 1")
commit = self.child_git_repo.HEAD
self.init_check()
r = self.assertReport(self.check, self.source)
- expected = git_mod.DroppedUnstableKeywords(['~amd64'], commit, pkg=CPV('cat/pkg-1'))
+ expected = git_mod.DroppedUnstableKeywords(["~amd64"], commit, pkg=CPV("cat/pkg-1"))
assert r == expected
def test_dropped_keywords_inherit_eclass(self):
# add stable ebuild to parent repo
- with open(pjoin(self.parent_git_repo.path, 'eclass/make.eclass'), 'w') as f:
- f.write(':')
- self.parent_git_repo.add_all('make.eclass: initial commit')
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['~amd64'], data="inherit make")
- self.parent_git_repo.add_all('cat/pkg: version bump to 1')
+ with open(pjoin(self.parent_git_repo.path, "eclass/make.eclass"), "w") as f:
+ f.write(":")
+ self.parent_git_repo.add_all("make.eclass: initial commit")
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["~amd64"], data="inherit make")
+ self.parent_git_repo.add_all("cat/pkg: version bump to 1")
# pull changes and remove it from the child repo
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_git_repo.remove('cat/pkg/pkg-1.ebuild', msg='cat/pkg: remove 1')
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_git_repo.remove("cat/pkg/pkg-1.ebuild", msg="cat/pkg: remove 1")
commit = self.child_git_repo.HEAD
self.init_check()
r = self.assertReport(self.check, self.source)
- expected = git_mod.DroppedUnstableKeywords(['~amd64'], commit, pkg=CPV('cat/pkg-1'))
+ expected = git_mod.DroppedUnstableKeywords(["~amd64"], commit, pkg=CPV("cat/pkg-1"))
assert r == expected
def test_rdepend_change(self):
# add pkgs to parent repo
- self.parent_repo.create_ebuild('cat/dep1-0')
- self.parent_git_repo.add_all('cat/dep1: initial import')
- self.parent_repo.create_ebuild('cat/dep2-0')
- self.parent_git_repo.add_all('cat/dep2: initial import')
- self.parent_repo.create_ebuild('newcat/newpkg-1')
- self.parent_git_repo.add_all('newcat/newpkg: initial import')
- self.parent_repo.create_ebuild('newcat/newpkg-2', rdepend="cat/dep1 cat/dep2")
- self.parent_git_repo.add_all('newcat/newpkg: version bump')
+ self.parent_repo.create_ebuild("cat/dep1-0")
+ self.parent_git_repo.add_all("cat/dep1: initial import")
+ self.parent_repo.create_ebuild("cat/dep2-0")
+ self.parent_git_repo.add_all("cat/dep2: initial import")
+ self.parent_repo.create_ebuild("newcat/newpkg-1")
+ self.parent_git_repo.add_all("newcat/newpkg: initial import")
+ self.parent_repo.create_ebuild("newcat/newpkg-2", rdepend="cat/dep1 cat/dep2")
+ self.parent_git_repo.add_all("newcat/newpkg: version bump")
# pull changes to child repo
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
# change pkg RDEPEND and commit
- with open(pjoin(self.child_git_repo.path, 'cat/pkg/pkg-0.ebuild'), 'a') as f:
+ with open(pjoin(self.child_git_repo.path, "cat/pkg/pkg-0.ebuild"), "a") as f:
f.write('RDEPEND="cat/dep1"\n')
- self.child_git_repo.add_all('cat/pkg: update deps')
+ self.child_git_repo.add_all("cat/pkg: update deps")
# change live pkg RDEPEND and commit
- with open(pjoin(self.child_git_repo.path, 'newcat/newpkg/newpkg-1.ebuild'), 'a') as f:
+ with open(pjoin(self.child_git_repo.path, "newcat/newpkg/newpkg-1.ebuild"), "a") as f:
f.write('RDEPEND="cat/dep1"\n')
f.write('PROPERTIES="live"\n')
- self.child_git_repo.add_all('newcat/newpkg: update deps')
+ self.child_git_repo.add_all("newcat/newpkg: update deps")
# reorder pkg RDEPEND and commit
- with open(pjoin(self.child_git_repo.path, 'newcat/newpkg/newpkg-2.ebuild'), 'a') as f:
+ with open(pjoin(self.child_git_repo.path, "newcat/newpkg/newpkg-2.ebuild"), "a") as f:
f.write('RDEPEND="cat/dep2 cat/dep1"\n')
- self.child_git_repo.add_all('newcat/newpkg: reorder deps')
+ self.child_git_repo.add_all("newcat/newpkg: reorder deps")
self.init_check()
r = self.assertReport(self.check, self.source)
# only one result is expected since live ebuilds are ignored
- expected = git_mod.RdependChange(pkg=CPV('cat/pkg-0'))
+ expected = git_mod.RdependChange(pkg=CPV("cat/pkg-0"))
assert r == expected
def test_missing_slotmove(self):
# add new ebuild to parent repo
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['~amd64'])
- self.parent_git_repo.add_all('cat/pkg: version bump to 1')
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["~amd64"])
+ self.parent_git_repo.add_all("cat/pkg: version bump to 1")
# pull changes and modify its slot in the child repo
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_repo.create_ebuild('cat/pkg-1', keywords=['~amd64'], slot='1')
- self.child_git_repo.add_all('cat/pkg: update SLOT to 1')
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_repo.create_ebuild("cat/pkg-1", keywords=["~amd64"], slot="1")
+ self.child_git_repo.add_all("cat/pkg: update SLOT to 1")
self.init_check()
r = self.assertReport(self.check, self.source)
- expected = git_mod.MissingSlotmove('0', '1', pkg=CPV('cat/pkg-1'))
+ expected = git_mod.MissingSlotmove("0", "1", pkg=CPV("cat/pkg-1"))
assert r == expected
# create slot move update and the result goes away
- updates_dir = pjoin(self.child_git_repo.path, 'profiles', 'updates')
+ updates_dir = pjoin(self.child_git_repo.path, "profiles", "updates")
os.makedirs(updates_dir, exist_ok=True)
- with open(pjoin(updates_dir, '4Q-2020'), 'w') as f:
- f.write(textwrap.dedent("""\
- slotmove ~cat/foo-0 0 1
- slotmove ~cat/pkg-1 0 1
- """))
+ with open(pjoin(updates_dir, "4Q-2020"), "w") as f:
+ f.write(
+ textwrap.dedent(
+ """\
+ slotmove ~cat/foo-0 0 1
+ slotmove ~cat/pkg-1 0 1
+ """
+ )
+ )
# force repo_config pkg updates jitted attr to be reset
self.init_check()
self.assertNoReport(self.check, self.source)
# git archive failures error out
- with patch('pkgcheck.checks.git.subprocess.Popen') as git_archive:
+ with patch("pkgcheck.checks.git.subprocess.Popen") as git_archive:
git_archive.return_value.poll.return_value = -1
- with pytest.raises(PkgcheckUserException, match='failed populating archive repo'):
+ with pytest.raises(PkgcheckUserException, match="failed populating archive repo"):
self.assertNoReport(self.check, self.source)
def test_missing_move(self):
# verify ebuild renames at the git level don't trigger
- self.child_repo.create_ebuild('cat/pkg-1')
- self.child_git_repo.run(['git', 'rm', 'cat/pkg/pkg-0.ebuild'])
- self.child_git_repo.add_all('cat/pkg: version bump and remove old')
+ self.child_repo.create_ebuild("cat/pkg-1")
+ self.child_git_repo.run(["git", "rm", "cat/pkg/pkg-0.ebuild"])
+ self.child_git_repo.add_all("cat/pkg: version bump and remove old")
self.init_check()
self.assertNoReport(self.check, self.source)
- self.child_git_repo.move('cat', 'newcat', msg='newcat/pkg: moved pkg')
+ self.child_git_repo.move("cat", "newcat", msg="newcat/pkg: moved pkg")
self.init_check()
r = self.assertReport(self.check, self.source)
- expected = git_mod.MissingMove('cat/pkg', 'newcat/pkg', pkg=CPV('newcat/pkg-0'))
+ expected = git_mod.MissingMove("cat/pkg", "newcat/pkg", pkg=CPV("newcat/pkg-0"))
assert r == expected
# create package move update and the result goes away
- updates_dir = pjoin(self.child_git_repo.path, 'profiles', 'updates')
+ updates_dir = pjoin(self.child_git_repo.path, "profiles", "updates")
os.makedirs(updates_dir, exist_ok=True)
- with open(pjoin(updates_dir, '4Q-2020'), 'w') as f:
- f.write(textwrap.dedent("""\
- move cat/foo newcat/foo
- move cat/pkg newcat/pkg
- """))
+ with open(pjoin(updates_dir, "4Q-2020"), "w") as f:
+ f.write(
+ textwrap.dedent(
+ """\
+ move cat/foo newcat/foo
+ move cat/pkg newcat/pkg
+ """
+ )
+ )
# force repo_config pkg updates jitted attr to be reset
self.init_check()
self.assertNoReport(self.check, self.source)
@@ -594,18 +633,17 @@ class TestGitEclassCommitsCheck(ReportTestCase):
# initialize parent repo
self.parent_git_repo = make_git_repo()
- self.parent_repo = make_repo(
- self.parent_git_repo.path, repo_id='gentoo', arches=['amd64'])
- self.parent_git_repo.add_all('initial commit')
+ self.parent_repo = make_repo(self.parent_git_repo.path, repo_id="gentoo", arches=["amd64"])
+ self.parent_git_repo.add_all("initial commit")
# create a stub eclass and commit it
- touch(pjoin(self.parent_git_repo.path, 'eclass', 'foo.eclass'))
- self.parent_git_repo.add_all('eclass: add foo eclass')
+ touch(pjoin(self.parent_git_repo.path, "eclass", "foo.eclass"))
+ self.parent_git_repo.add_all("eclass: add foo eclass")
# initialize child repo
self.child_git_repo = make_git_repo()
- self.child_git_repo.run(['git', 'remote', 'add', 'origin', self.parent_git_repo.path])
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_git_repo.run(['git', 'remote', 'set-head', 'origin', 'main'])
+ self.child_git_repo.run(["git", "remote", "add", "origin", self.parent_git_repo.path])
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_git_repo.run(["git", "remote", "set-head", "origin", "main"])
self.child_repo = make_repo(self.child_git_repo.path)
def init_check(self, options=None, future=0):
@@ -618,35 +656,40 @@ class TestGitEclassCommitsCheck(ReportTestCase):
def _options(self, **kwargs):
args = [
- 'scan', '-q', '--cache-dir', self.cache_dir,
- '--repo', self.child_repo.location, '--commits',
+ "scan",
+ "-q",
+ "--cache-dir",
+ self.cache_dir,
+ "--repo",
+ self.child_repo.location,
+ "--commits",
]
options, _ = self._tool.parse_args(args)
return options
def test_eclass_incorrect_copyright(self):
- line = '# Copyright 1999-2019 Gentoo Authors'
- with open(pjoin(self.child_git_repo.path, 'eclass/foo.eclass'), 'w') as f:
- f.write(f'{line}\n')
- self.child_git_repo.add_all('eclass: update foo')
+ line = "# Copyright 1999-2019 Gentoo Authors"
+ with open(pjoin(self.child_git_repo.path, "eclass/foo.eclass"), "w") as f:
+ f.write(f"{line}\n")
+ self.child_git_repo.add_all("eclass: update foo")
self.init_check()
r = self.assertReport(self.check, self.source)
- expected = git_mod.EclassIncorrectCopyright('2019', line, eclass='foo')
+ expected = git_mod.EclassIncorrectCopyright("2019", line, eclass="foo")
assert r == expected
# correcting the year results in no report
year = datetime.today().year
- line = f'# Copyright 1999-{year} Gentoo Authors'
- with open(pjoin(self.child_git_repo.path, 'eclass/foo.eclass'), 'w') as f:
- f.write(f'{line}\n')
- self.child_git_repo.add_all('eclass: fix copyright year')
+ line = f"# Copyright 1999-{year} Gentoo Authors"
+ with open(pjoin(self.child_git_repo.path, "eclass/foo.eclass"), "w") as f:
+ f.write(f"{line}\n")
+ self.child_git_repo.add_all("eclass: fix copyright year")
self.init_check()
self.assertNoReport(self.check, self.source)
def test_eclass_missing_copyright(self):
"""Eclasses missing copyrights entirely are handled by EclassHeaderCheck."""
- with open(pjoin(self.child_git_repo.path, 'eclass/foo.eclass'), 'w') as f:
- f.write('# comment\n')
- self.child_git_repo.add_all('eclass: update foo')
+ with open(pjoin(self.child_git_repo.path, "eclass/foo.eclass"), "w") as f:
+ f.write("# comment\n")
+ self.child_git_repo.add_all("eclass: update foo")
self.init_check()
self.assertNoReport(self.check, self.source)
diff --git a/tests/checks/test_glsa.py b/tests/checks/test_glsa.py
index c3182be1..bec35857 100644
--- a/tests/checks/test_glsa.py
+++ b/tests/checks/test_glsa.py
@@ -31,34 +31,34 @@ class TestVulnerabilitiesCheck(misc.ReportTestCase):
def test_no_glsa_dir(self, tmp_path):
# TODO: switch to using a repo fixture when available
repo_dir = str(tmp_path)
- os.makedirs(pjoin(repo_dir, 'profiles'))
- os.makedirs(pjoin(repo_dir, 'metadata'))
- with open(pjoin(repo_dir, 'profiles', 'repo_name'), 'w') as f:
- f.write('fake\n')
- with open(pjoin(repo_dir, 'metadata', 'layout.conf'), 'w') as f:
- f.write('masters =\n')
+ os.makedirs(pjoin(repo_dir, "profiles"))
+ os.makedirs(pjoin(repo_dir, "metadata"))
+ with open(pjoin(repo_dir, "profiles", "repo_name"), "w") as f:
+ f.write("fake\n")
+ with open(pjoin(repo_dir, "metadata", "layout.conf"), "w") as f:
+ f.write("masters =\n")
repo_config = repo_objs.RepoConfig(location=repo_dir)
repo = repository.UnconfiguredTree(repo_config.location, repo_config=repo_config)
options = arghparse.Namespace(glsa_dir=None, target_repo=repo, gentoo_repo=True)
- with pytest.raises(SkipCheck, match='no available glsa source'):
+ with pytest.raises(SkipCheck, match="no available glsa source"):
glsa.GlsaCheck(options)
def test_repo_glsa_dir(self, tmp_path):
# TODO: switch to using a repo fixture when available
repo_dir = str(tmp_path)
- os.makedirs(pjoin(repo_dir, 'profiles'))
- os.makedirs(pjoin(repo_dir, 'metadata', 'glsa'))
- with open(pjoin(repo_dir, 'profiles', 'repo_name'), 'w') as f:
- f.write('fake\n')
- with open(pjoin(repo_dir, 'metadata', 'layout.conf'), 'w') as f:
- f.write('masters =\n')
- with open(pjoin(repo_dir, 'metadata', 'glsa', 'glsa-202010-01.xml'), 'w') as f:
+ os.makedirs(pjoin(repo_dir, "profiles"))
+ os.makedirs(pjoin(repo_dir, "metadata", "glsa"))
+ with open(pjoin(repo_dir, "profiles", "repo_name"), "w") as f:
+ f.write("fake\n")
+ with open(pjoin(repo_dir, "metadata", "layout.conf"), "w") as f:
+ f.write("masters =\n")
+ with open(pjoin(repo_dir, "metadata", "glsa", "glsa-202010-01.xml"), "w") as f:
f.write(mk_glsa(("dev-util/diffball", ([], ["~>=0.5-r3"]))))
repo_config = repo_objs.RepoConfig(location=repo_dir)
repo = repository.UnconfiguredTree(repo_config.location, repo_config=repo_config)
options = arghparse.Namespace(glsa_dir=None, target_repo=repo, gentoo_repo=True)
check = glsa.GlsaCheck(options)
- assert 'dev-util/diffball' in check.vulns
+ assert "dev-util/diffball" in check.vulns
def test_non_matching(self, check):
self.assertNoReport(check, mk_pkg("0.5.1"))
@@ -67,10 +67,8 @@ class TestVulnerabilitiesCheck(misc.ReportTestCase):
def test_matching(self, check):
r = self.assertReport(check, mk_pkg("0.5-r5"))
assert isinstance(r, glsa.VulnerablePackage)
- assert (
- (r.category, r.package, r.version) ==
- ("dev-util", "diffball", "0.5-r5"))
- assert 'vulnerable via glsa(200611-02)' in str(r)
+ assert (r.category, r.package, r.version) == ("dev-util", "diffball", "0.5-r5")
+ assert "vulnerable via glsa(200611-02)" in str(r)
# multiple glsa matches
self.assertReports(check, mk_pkg("1.0"))
diff --git a/tests/checks/test_header.py b/tests/checks/test_header.py
index 492c3d8c..e79fdeb1 100644
--- a/tests/checks/test_header.py
+++ b/tests/checks/test_header.py
@@ -21,9 +21,9 @@ class TestEbuildHeaderCheck(misc.ReportTestCase):
def test_good_copyright(self):
good_copyrights = [
- '# Copyright 1999-2019 Gentoo Authors\n',
- '# Copyright 2019 Gentoo Authors\n',
- '# Copyright 2010-2017 Gentoo Authors\n',
+ "# Copyright 1999-2019 Gentoo Authors\n",
+ "# Copyright 2019 Gentoo Authors\n",
+ "# Copyright 2010-2017 Gentoo Authors\n",
]
for line in good_copyrights:
fake_src = [line, self.check_kls.license_header]
@@ -32,11 +32,11 @@ class TestEbuildHeaderCheck(misc.ReportTestCase):
def test_invalid_copyright(self):
bad_copyrights = [
- '# Copyright (c) 1999-2019 Gentoo Authors\n',
- '# Copyright Gentoo Authors\n',
- '# Gentoo Authors\n',
- '# Here is entirely random text\n',
- '\n',
+ "# Copyright (c) 1999-2019 Gentoo Authors\n",
+ "# Copyright Gentoo Authors\n",
+ "# Gentoo Authors\n",
+ "# Here is entirely random text\n",
+ "\n",
]
for line in bad_copyrights:
fake_src = [line, self.check_kls.license_header]
@@ -48,10 +48,10 @@ class TestEbuildHeaderCheck(misc.ReportTestCase):
def test_new_foundation_copyright(self):
"""Foundation copyright on new ebuilds triggers the report."""
bad_copyrights = [
- '# Copyright 1999-2019 Gentoo Foundation\n',
- '# Copyright 2019 Gentoo Foundation\n',
- '# Copyright 3125 Gentoo Foundation\n',
- '# Copyright 2010-2021 Gentoo Foundation\n',
+ "# Copyright 1999-2019 Gentoo Foundation\n",
+ "# Copyright 2019 Gentoo Foundation\n",
+ "# Copyright 3125 Gentoo Foundation\n",
+ "# Copyright 2010-2021 Gentoo Foundation\n",
]
for line in bad_copyrights:
fake_src = [line, self.check_kls.license_header]
@@ -63,9 +63,9 @@ class TestEbuildHeaderCheck(misc.ReportTestCase):
def test_old_foundation_copyright(self):
"""Foundation copyright on old ebuilds does not trigger false positives."""
good_copyrights = [
- '# Copyright 1999-2018 Gentoo Foundation\n',
- '# Copyright 2016 Gentoo Foundation\n',
- '# Copyright 2010-2017 Gentoo Foundation\n',
+ "# Copyright 1999-2018 Gentoo Foundation\n",
+ "# Copyright 2016 Gentoo Foundation\n",
+ "# Copyright 2010-2017 Gentoo Foundation\n",
]
for line in good_copyrights:
fake_src = [line, self.check_kls.license_header]
@@ -75,8 +75,8 @@ class TestEbuildHeaderCheck(misc.ReportTestCase):
def test_non_gentoo_authors_copyright_in_gentoo(self):
"""Ebuilds in the gentoo repo must use 'Gentoo Authors'."""
bad_copyrights = [
- '# Copyright 1999-2019 D. E. Veloper\n',
- '# Copyright 2019 辣鸡汤\n',
+ "# Copyright 1999-2019 D. E. Veloper\n",
+ "# Copyright 2019 辣鸡汤\n",
]
for line in bad_copyrights:
fake_src = [line, self.check_kls.license_header]
@@ -86,23 +86,23 @@ class TestEbuildHeaderCheck(misc.ReportTestCase):
assert line.strip() in str(r)
def test_license_headers(self):
- copyright = '# Copyright 1999-2019 Gentoo Authors\n'
+ copyright = "# Copyright 1999-2019 Gentoo Authors\n"
fake_src = [copyright, self.check_kls.license_header]
fake_pkg = self.mk_pkg(lines=fake_src)
self.assertNoReport(self.mk_check(), fake_pkg)
bad_license_headers = [
[],
- [''],
- ['\n'],
- [f'{self.check_kls.license_header} '],
- [f' {self.check_kls.license_header}'],
- ['# Distributed under the terms of the GNU General Public License v3'],
+ [""],
+ ["\n"],
+ [f"{self.check_kls.license_header} "],
+ [f" {self.check_kls.license_header}"],
+ ["# Distributed under the terms of the GNU General Public License v3"],
]
for content in bad_license_headers:
fake_src = [copyright] + content
fake_pkg = self.mk_pkg(lines=fake_src)
r = self.assertReport(self.mk_check(), fake_pkg)
assert isinstance(r, header.EbuildInvalidLicenseHeader)
- expected = content[0].strip() if content else 'missing license header'
+ expected = content[0].strip() if content else "missing license header"
assert expected in str(r)
diff --git a/tests/checks/test_imlate.py b/tests/checks/test_imlate.py
index 3c0f44f8..624dc90a 100644
--- a/tests/checks/test_imlate.py
+++ b/tests/checks/test_imlate.py
@@ -4,21 +4,25 @@ from snakeoil.cli import arghparse
from .. import misc
-def mk_check(selected_arches=("x86", "ppc", "amd64"), arches=None,
- stable_arches=None, source_arches=None):
+def mk_check(
+ selected_arches=("x86", "ppc", "amd64"), arches=None, stable_arches=None, source_arches=None
+):
if arches is None:
arches = selected_arches
if stable_arches is None:
stable_arches = selected_arches
return imlate.ImlateCheck(
arghparse.Namespace(
- selected_arches=selected_arches, arches=arches,
- stable_arches=stable_arches, source_arches=source_arches))
+ selected_arches=selected_arches,
+ arches=arches,
+ stable_arches=stable_arches,
+ source_arches=source_arches,
+ )
+ )
def mk_pkg(ver, keywords="", slot="0"):
- return misc.FakePkg(
- f"dev-util/diffball-{ver}", data={"SLOT": slot, "KEYWORDS": keywords})
+ return misc.FakePkg(f"dev-util/diffball-{ver}", data={"SLOT": slot, "KEYWORDS": keywords})
class TestImlateCheck(misc.ReportTestCase):
@@ -26,96 +30,82 @@ class TestImlateCheck(misc.ReportTestCase):
check_kls = imlate.ImlateCheck
def test_all_unstable(self):
- self.assertNoReport(
- mk_check(),
- [mk_pkg(str(x), "~x86 ~amd64") for x in range(10)])
+ self.assertNoReport(mk_check(), [mk_pkg(str(x), "~x86 ~amd64") for x in range(10)])
def test_all_stable(self):
- self.assertNoReport(
- mk_check(),
- [mk_pkg("0.9", "amd64 x86")])
+ self.assertNoReport(mk_check(), [mk_pkg("0.9", "amd64 x86")])
def test_unselected_arch(self):
- self.assertNoReport(
- mk_check(),
- [mk_pkg("0.9", "~mips amd64")])
+ self.assertNoReport(mk_check(), [mk_pkg("0.9", "~mips amd64")])
def test_specified_stable_arches(self):
# pkg doesn't have any unstable arches we care about
- self.assertNoReport(
- mk_check(source_arches=('arm', 'arm64')),
- [mk_pkg("0.9", "~x86 amd64")])
+ self.assertNoReport(mk_check(source_arches=("arm", "arm64")), [mk_pkg("0.9", "~x86 amd64")])
# pkg doesn't have any stable arches we care about
- self.assertNoReport(
- mk_check(source_arches=('arm64',)),
- [mk_pkg("0.9", "~x86 amd64")])
+ self.assertNoReport(mk_check(source_arches=("arm64",)), [mk_pkg("0.9", "~x86 amd64")])
# only flag arches we care about
r = self.assertReport(
- mk_check(source_arches=('amd64',), selected_arches=('arm64',)),
- [mk_pkg("0.9", "~arm64 ~x86 amd64")])
+ mk_check(source_arches=("amd64",), selected_arches=("arm64",)),
+ [mk_pkg("0.9", "~arm64 ~x86 amd64")],
+ )
assert isinstance(r, imlate.PotentialStable)
assert r.stable == ("amd64",)
assert r.keywords == ("~arm64",)
assert r.version == "0.9"
def test_lagging_keyword(self):
- r = self.assertReport(
- mk_check(),
- [mk_pkg("0.8", "x86 amd64"),
- mk_pkg("0.9", "x86 ~amd64")])
+ r = self.assertReport(mk_check(), [mk_pkg("0.8", "x86 amd64"), mk_pkg("0.9", "x86 ~amd64")])
assert isinstance(r, imlate.LaggingStable)
assert r.stable == ("x86",)
assert r.keywords == ("~amd64",)
assert r.version == "0.9"
- assert 'x86' in str(r) and '~amd64' in str(r)
+ assert "x86" in str(r) and "~amd64" in str(r)
def test_potential_keyword(self):
- r = self.assertReport(
- mk_check(),
- [mk_pkg("0.9", "~x86 amd64")])
+ r = self.assertReport(mk_check(), [mk_pkg("0.9", "~x86 amd64")])
assert isinstance(r, imlate.PotentialStable)
assert r.stable == ("amd64",)
assert r.keywords == ("~x86",)
assert r.version == "0.9"
- assert 'amd64' in str(r) and '~x86' in str(r)
+ assert "amd64" in str(r) and "~x86" in str(r)
def test_multiple_unstable_pkgs(self):
r = self.assertReport(
- mk_check(),
- [mk_pkg("0.7", "~x86"),
- mk_pkg("0.8", "~x86"),
- mk_pkg("0.9", "~x86 amd64")])
+ mk_check(), [mk_pkg("0.7", "~x86"), mk_pkg("0.8", "~x86"), mk_pkg("0.9", "~x86 amd64")]
+ )
assert r.stable == ("amd64",)
assert r.keywords == ("~x86",)
assert r.version == "0.9"
def test_multiple_stable_arches(self):
r = self.assertReport(
- mk_check(),
- [mk_pkg("0.7", "~x86 ~ppc"),
- mk_pkg("0.9", "~x86 ppc amd64")])
+ mk_check(), [mk_pkg("0.7", "~x86 ~ppc"), mk_pkg("0.9", "~x86 ppc amd64")]
+ )
assert r.stable == ("amd64", "ppc")
assert r.keywords == ("~x86",)
assert r.version == "0.9"
def test_multiple_potential_arches(self):
- r = self.assertReport(
- mk_check(),
- [mk_pkg("0.7", "~x86"),
- mk_pkg("0.9", "~x86 ~ppc amd64")])
+ r = self.assertReport(mk_check(), [mk_pkg("0.7", "~x86"), mk_pkg("0.9", "~x86 ~ppc amd64")])
assert r.stable == ("amd64",)
- assert r.keywords == ("~ppc", "~x86",)
+ assert r.keywords == (
+ "~ppc",
+ "~x86",
+ )
assert r.version == "0.9"
def test_multiple_lagging_slots(self):
r = self.assertReports(
mk_check(),
- [mk_pkg("0.7", slot="0", keywords="x86 ppc"),
- mk_pkg("0.9", slot="0", keywords="~x86 ppc"),
- mk_pkg("1.0", slot="1", keywords="x86 ppc"),
- mk_pkg("1.2", slot="1", keywords="x86 ~ppc")])
+ [
+ mk_pkg("0.7", slot="0", keywords="x86 ppc"),
+ mk_pkg("0.9", slot="0", keywords="~x86 ppc"),
+ mk_pkg("1.0", slot="1", keywords="x86 ppc"),
+ mk_pkg("1.2", slot="1", keywords="x86 ~ppc"),
+ ],
+ )
assert len(r) == 2
assert isinstance(r[0], imlate.LaggingStable)
assert r[0].slot == "0"
@@ -131,8 +121,11 @@ class TestImlateCheck(misc.ReportTestCase):
def test_multiple_potential_slots(self):
r = self.assertReports(
mk_check(),
- [mk_pkg("0.9", slot="0", keywords="x86 ~ppc"),
- mk_pkg("1.2", slot="1", keywords="x86 ~ppc")])
+ [
+ mk_pkg("0.9", slot="0", keywords="x86 ~ppc"),
+ mk_pkg("1.2", slot="1", keywords="x86 ~ppc"),
+ ],
+ )
assert len(r) == 2
assert isinstance(r[0], imlate.PotentialStable)
assert r[0].slot == "0"
@@ -146,15 +139,17 @@ class TestImlateCheck(misc.ReportTestCase):
assert r[1].version == "1.2"
def test_drop_newer_slot_stables(self):
- selected_arches=("x86", "amd64")
- all_arches=("x86", "amd64", "arm64")
+ selected_arches = ("x86", "amd64")
+ all_arches = ("x86", "amd64", "arm64")
r = self.assertReport(
mk_check(selected_arches=selected_arches, arches=all_arches),
- [mk_pkg("0.7", "amd64 x86 ~arm64"),
- mk_pkg("0.8", "amd64 ~x86 ~arm64"),
- mk_pkg("0.9", "~amd64 ~x86 arm64")]
+ [
+ mk_pkg("0.7", "amd64 x86 ~arm64"),
+ mk_pkg("0.8", "amd64 ~x86 ~arm64"),
+ mk_pkg("0.9", "~amd64 ~x86 arm64"),
+ ],
)
assert isinstance(r, imlate.LaggingStable)
- assert r.stable == ('amd64',)
- assert r.keywords == ('~x86',)
- assert r.version == '0.8'
+ assert r.stable == ("amd64",)
+ assert r.keywords == ("~x86",)
+ assert r.version == "0.8"
diff --git a/tests/checks/test_metadata.py b/tests/checks/test_metadata.py
index cc074d93..ee0ac08e 100644
--- a/tests/checks/test_metadata.py
+++ b/tests/checks/test_metadata.py
@@ -30,27 +30,24 @@ class TestDescriptionCheck(misc.ReportTestCase):
self.assertNoReport(self.check, self.mk_pkg("a perfectly written package description"))
def test_bad_descs(self):
- for desc in ('based on eclass',
- 'diffball',
- 'dev-util/diffball',
- 'foon'):
+ for desc in ("based on eclass", "diffball", "dev-util/diffball", "foon"):
r = self.assertReport(self.check, self.mk_pkg(desc))
assert isinstance(r, metadata.BadDescription)
def test_desc_length(self):
r = self.assertReport(self.check, self.mk_pkg())
assert isinstance(r, metadata.BadDescription)
- assert 'empty/unset' in str(r)
+ assert "empty/unset" in str(r)
- self.assertNoReport(self.check, self.mk_pkg('s' * 80))
- r = self.assertReport(self.check, self.mk_pkg('s' * 81))
+ self.assertNoReport(self.check, self.mk_pkg("s" * 80))
+ r = self.assertReport(self.check, self.mk_pkg("s" * 81))
assert isinstance(r, metadata.BadDescription)
- assert 'over 80 chars in length' in str(r)
+ assert "over 80 chars in length" in str(r)
- self.assertNoReport(self.check, self.mk_pkg('s' * 10))
- r = self.assertReport(self.check, self.mk_pkg('s' * 9))
+ self.assertNoReport(self.check, self.mk_pkg("s" * 10))
+ r = self.assertReport(self.check, self.mk_pkg("s" * 9))
assert isinstance(r, metadata.BadDescription)
- assert 'under 10 chars in length' in str(r)
+ assert "under 10 chars in length" in str(r)
class TestHomepageCheck(misc.ReportTestCase):
@@ -58,7 +55,7 @@ class TestHomepageCheck(misc.ReportTestCase):
check_kls = metadata.HomepageCheck
check = metadata.HomepageCheck(None)
- def mk_pkg(self, homepage='', cpvstr='dev-util/diffball-0.7.1'):
+ def mk_pkg(self, homepage="", cpvstr="dev-util/diffball-0.7.1"):
return misc.FakePkg(cpvstr, data={"HOMEPAGE": homepage})
def test_regular(self):
@@ -72,26 +69,26 @@ class TestHomepageCheck(misc.ReportTestCase):
def test_unset(self):
r = self.assertReport(self.check, self.mk_pkg())
isinstance(r, metadata.BadHomepage)
- assert 'empty/unset' in str(r)
+ assert "empty/unset" in str(r)
# categories of pkgs allowed to skip HOMEPAGE
for cat in self.check_kls.missing_categories:
- self.assertNoReport(self.check, self.mk_pkg(cpvstr=f'{cat}/foo-0'))
+ self.assertNoReport(self.check, self.mk_pkg(cpvstr=f"{cat}/foo-0"))
def test_no_protocol(self):
- r = self.assertReport(self.check, self.mk_pkg('foobar.com'))
+ r = self.assertReport(self.check, self.mk_pkg("foobar.com"))
isinstance(r, metadata.BadHomepage)
- assert 'lacks protocol' in str(r)
+ assert "lacks protocol" in str(r)
def test_unsupported_protocol(self):
- r = self.assertReport(self.check, self.mk_pkg('htp://foobar.com'))
+ r = self.assertReport(self.check, self.mk_pkg("htp://foobar.com"))
isinstance(r, metadata.BadHomepage)
assert "uses unsupported protocol 'htp'" in str(r)
def test_unspecific_site(self):
- for suffix in ('', '/'):
- for site in ('https://www.gentoo.org', 'https://gentoo.org'):
- r = self.assertReport(self.check, self.mk_pkg(f'{site}{suffix}'))
+ for suffix in ("", "/"):
+ for site in ("https://www.gentoo.org", "https://gentoo.org"):
+ r = self.assertReport(self.check, self.mk_pkg(f"{site}{suffix}"))
isinstance(r, metadata.BadHomepage)
assert "unspecific HOMEPAGE" in str(r)
@@ -104,27 +101,30 @@ class TestHomepageCheck(misc.ReportTestCase):
class IUSE_Options(misc.Tmpdir):
-
def get_options(self, properties=(), restrict=(), **kwargs):
repo_base = tempfile.mkdtemp(dir=self.dir)
- base = pjoin(repo_base, 'profiles')
+ base = pjoin(repo_base, "profiles")
os.mkdir(base)
- with open(pjoin(base, "arch.list"), 'w') as file:
+ with open(pjoin(base, "arch.list"), "w") as file:
file.write("\n".join(kwargs.pop("arches", ("x86", "ppc", "amd64", "amd64-fbsd"))))
with open(pjoin(base, "use.desc"), "w") as file:
file.write("\n".join(f"{x} - {x}" for x in kwargs.pop("use_desc", ("foo", "bar"))))
- with open(pjoin(base, 'repo_name'), 'w') as file:
- file.write(kwargs.pop('repo_name', 'monkeys'))
- os.mkdir(pjoin(repo_base, 'metadata'))
- with open(pjoin(repo_base, 'metadata', 'layout.conf'), 'w') as f:
- f.write(textwrap.dedent(f"""\
- masters =
- properties-allowed = {' '.join(properties)}
- restrict-allowed = {' '.join(restrict)}
- """))
- kwargs['target_repo'] = repository.UnconfiguredTree(repo_base)
- kwargs.setdefault('verbosity', 0)
- kwargs.setdefault('cache', {'git': False})
+ with open(pjoin(base, "repo_name"), "w") as file:
+ file.write(kwargs.pop("repo_name", "monkeys"))
+ os.mkdir(pjoin(repo_base, "metadata"))
+ with open(pjoin(repo_base, "metadata", "layout.conf"), "w") as f:
+ f.write(
+ textwrap.dedent(
+ f"""\
+ masters =
+ properties-allowed = {' '.join(properties)}
+ restrict-allowed = {' '.join(restrict)}
+ """
+ )
+ )
+ kwargs["target_repo"] = repository.UnconfiguredTree(repo_base)
+ kwargs.setdefault("verbosity", 0)
+ kwargs.setdefault("cache", {"git": False})
return arghparse.Namespace(**kwargs)
@@ -135,21 +135,21 @@ class TestKeywordsCheck(IUSE_Options, misc.ReportTestCase):
@pytest.fixture
def check(self):
pkgs = (
- FakePkg('dev-libs/foo-0', keywords=('amd64', '~x86')),
- FakePkg('dev-libs/foo-1', keywords=('-*', 'ppc')),
- FakePkg('dev-libs/bar-2', keywords=()),
+ FakePkg("dev-libs/foo-0", keywords=("amd64", "~x86")),
+ FakePkg("dev-libs/foo-1", keywords=("-*", "ppc")),
+ FakePkg("dev-libs/bar-2", keywords=()),
)
search_repo = FakeRepo(pkgs=pkgs)
options = self.get_options(search_repo=search_repo, gentoo_repo=False)
kwargs = {
- 'use_addon': addons.UseAddon(options),
- 'keywords_addon': addons.KeywordsAddon(options),
+ "use_addon": addons.UseAddon(options),
+ "keywords_addon": addons.KeywordsAddon(options),
}
return metadata.KeywordsCheck(options, **kwargs)
- def mk_pkg(self, keywords='', cpv='dev-util/diffball-0.7.1', rdepend=''):
- return misc.FakePkg(cpv, data={'KEYWORDS': keywords, 'RDEPEND': rdepend})
+ def mk_pkg(self, keywords="", cpv="dev-util/diffball-0.7.1", rdepend=""):
+ return misc.FakePkg(cpv, data={"KEYWORDS": keywords, "RDEPEND": rdepend})
def test_no_keywords(self, check):
self.assertNoReport(check, self.mk_pkg())
@@ -173,23 +173,23 @@ class TestKeywordsCheck(IUSE_Options, misc.ReportTestCase):
# unknown keyword
r = self.assertReport(check, self.mk_pkg("foo"))
assert isinstance(r, metadata.UnknownKeywords)
- assert r.keywords == ('foo',)
+ assert r.keywords == ("foo",)
assert "unknown KEYWORDS: 'foo'" in str(r)
# check that * and ~* are flagged in gentoo repo
- options = self.get_options(repo_name='gentoo', gentoo_repo=True)
+ options = self.get_options(repo_name="gentoo", gentoo_repo=True)
kwargs = {
- 'use_addon': addons.UseAddon(options),
- 'keywords_addon': addons.KeywordsAddon(options),
+ "use_addon": addons.UseAddon(options),
+ "keywords_addon": addons.KeywordsAddon(options),
}
check = metadata.KeywordsCheck(options, **kwargs)
r = self.assertReport(check, self.mk_pkg("*"))
assert isinstance(r, metadata.UnknownKeywords)
- assert r.keywords == ('*',)
+ assert r.keywords == ("*",)
assert "unknown KEYWORDS: '*'" in str(r)
r = self.assertReport(check, self.mk_pkg("~*"))
assert isinstance(r, metadata.UnknownKeywords)
- assert r.keywords == ('~*',)
+ assert r.keywords == ("~*",)
assert "unknown KEYWORDS: '~*'" in str(r)
def test_overlapping_keywords(self, check):
@@ -214,78 +214,78 @@ class TestKeywordsCheck(IUSE_Options, misc.ReportTestCase):
# single duplicate
r = self.assertReport(check, self.mk_pkg("amd64 amd64"))
assert isinstance(r, metadata.DuplicateKeywords)
- assert r.keywords == ('amd64',)
- assert 'duplicate KEYWORDS: amd64' in str(r)
+ assert r.keywords == ("amd64",)
+ assert "duplicate KEYWORDS: amd64" in str(r)
# multiple duplicates
r = self.assertReport(check, self.mk_pkg("-* -* amd64 amd64 ~x86 ~x86"))
assert isinstance(r, metadata.DuplicateKeywords)
- assert r.keywords == ('-*', 'amd64', '~x86')
+ assert r.keywords == ("-*", "amd64", "~x86")
def test_unsorted_keywords(self, check):
# regular keywords
- self.assertNoReport(check, self.mk_pkg('-* ~amd64'))
+ self.assertNoReport(check, self.mk_pkg("-* ~amd64"))
# prefix keywords come after regular keywords
- self.assertNoReport(check, self.mk_pkg('~amd64 ppc ~x86 ~amd64-fbsd'))
+ self.assertNoReport(check, self.mk_pkg("~amd64 ppc ~x86 ~amd64-fbsd"))
# non-verbose mode doesn't show sorted keywords
- r = self.assertReport(check, self.mk_pkg('~amd64 -*'))
+ r = self.assertReport(check, self.mk_pkg("~amd64 -*"))
assert isinstance(r, metadata.UnsortedKeywords)
- assert r.keywords == ('~amd64', '-*')
+ assert r.keywords == ("~amd64", "-*")
assert r.sorted_keywords == ()
- assert 'unsorted KEYWORDS: ~amd64, -*' in str(r)
+ assert "unsorted KEYWORDS: ~amd64, -*" in str(r)
# create a check instance with verbose mode enabled
options = self.get_options(gentoo_repo=False, verbosity=1)
kwargs = {
- 'use_addon': addons.UseAddon(options),
- 'keywords_addon': addons.KeywordsAddon(options),
+ "use_addon": addons.UseAddon(options),
+ "keywords_addon": addons.KeywordsAddon(options),
}
check = metadata.KeywordsCheck(options, **kwargs)
# masks should come before regular keywords
- r = self.assertReport(check, self.mk_pkg('~amd64 -*'))
+ r = self.assertReport(check, self.mk_pkg("~amd64 -*"))
assert isinstance(r, metadata.UnsortedKeywords)
- assert r.keywords == ('~amd64', '-*')
- assert r.sorted_keywords == ('-*', '~amd64')
- assert '\n\tunsorted KEYWORDS: ~amd64, -*\n\tsorted KEYWORDS: -*, ~amd64' in str(r)
+ assert r.keywords == ("~amd64", "-*")
+ assert r.sorted_keywords == ("-*", "~amd64")
+ assert "\n\tunsorted KEYWORDS: ~amd64, -*\n\tsorted KEYWORDS: -*, ~amd64" in str(r)
# keywords should be sorted alphabetically by arch
- r = self.assertReport(check, self.mk_pkg('ppc ~amd64'))
+ r = self.assertReport(check, self.mk_pkg("ppc ~amd64"))
assert isinstance(r, metadata.UnsortedKeywords)
- assert r.keywords == ('ppc', '~amd64')
- assert r.sorted_keywords == ('~amd64', 'ppc')
- assert '\n\tunsorted KEYWORDS: ppc, ~amd64\n\tsorted KEYWORDS: ~amd64, ppc' in str(r)
+ assert r.keywords == ("ppc", "~amd64")
+ assert r.sorted_keywords == ("~amd64", "ppc")
+ assert "\n\tunsorted KEYWORDS: ppc, ~amd64\n\tsorted KEYWORDS: ~amd64, ppc" in str(r)
# prefix keywords should come after regular keywords
- r = self.assertReport(check, self.mk_pkg('~amd64 ~amd64-fbsd ppc ~x86'))
+ r = self.assertReport(check, self.mk_pkg("~amd64 ~amd64-fbsd ppc ~x86"))
assert isinstance(r, metadata.UnsortedKeywords)
- assert r.keywords == ('~amd64', '~amd64-fbsd', 'ppc', '~x86')
- assert r.sorted_keywords == ('~amd64', 'ppc', '~x86', '~amd64-fbsd')
+ assert r.keywords == ("~amd64", "~amd64-fbsd", "ppc", "~x86")
+ assert r.sorted_keywords == ("~amd64", "ppc", "~x86", "~amd64-fbsd")
def test_missing_virtual_keywords(self, check):
# non-virtuals don't trigger
- pkg = self.mk_pkg(cpv='dev-util/foo-0', rdepend='=dev-libs/foo-0')
+ pkg = self.mk_pkg(cpv="dev-util/foo-0", rdepend="=dev-libs/foo-0")
self.assertNoReport(check, pkg)
# matching pkg with no keywords
- pkg = self.mk_pkg(cpv='virtual/foo-0', rdepend='dev-libs/bar')
+ pkg = self.mk_pkg(cpv="virtual/foo-0", rdepend="dev-libs/bar")
self.assertNoReport(check, pkg)
# single pkg match
- pkg = self.mk_pkg(cpv='virtual/foo-0', rdepend='=dev-libs/foo-0')
+ pkg = self.mk_pkg(cpv="virtual/foo-0", rdepend="=dev-libs/foo-0")
r = self.assertReport(check, pkg)
assert isinstance(r, metadata.VirtualKeywordsUpdate)
- assert r.keywords == ('amd64', '~x86')
- assert 'KEYWORDS updates available: amd64, ~x86' in str(r)
+ assert r.keywords == ("amd64", "~x86")
+ assert "KEYWORDS updates available: amd64, ~x86" in str(r)
# multiple pkg match
- pkg = self.mk_pkg(cpv='virtual/foo-0', rdepend='dev-libs/foo')
+ pkg = self.mk_pkg(cpv="virtual/foo-0", rdepend="dev-libs/foo")
r = self.assertReport(check, pkg)
assert isinstance(r, metadata.VirtualKeywordsUpdate)
- assert r.keywords == ('amd64', 'ppc', '~x86')
- assert 'KEYWORDS updates available: amd64, ppc, ~x86' in str(r)
+ assert r.keywords == ("amd64", "ppc", "~x86")
+ assert "KEYWORDS updates available: amd64, ppc, ~x86" in str(r)
class TestIuseCheck(IUSE_Options, misc.ReportTestCase):
@@ -298,28 +298,28 @@ class TestIuseCheck(IUSE_Options, misc.ReportTestCase):
use_addon = addons.UseAddon(options)
return self.check_kls(options, use_addon=use_addon)
- def mk_pkg(self, iuse=''):
- return misc.FakePkg('dev-util/diffball-0.7.1', data={'IUSE': iuse, 'EAPI': '1'})
+ def mk_pkg(self, iuse=""):
+ return misc.FakePkg("dev-util/diffball-0.7.1", data={"IUSE": iuse, "EAPI": "1"})
def test_known_iuse(self, check):
- self.assertNoReport(check, self.mk_pkg('foo bar'))
+ self.assertNoReport(check, self.mk_pkg("foo bar"))
def test_unknown_iuse(self, check):
- r = self.assertReport(check, self.mk_pkg('foo dar'))
+ r = self.assertReport(check, self.mk_pkg("foo dar"))
assert isinstance(r, metadata.UnknownUseFlags)
- assert r.flags == ('dar',)
- assert 'dar' in str(r)
+ assert r.flags == ("dar",)
+ assert "dar" in str(r)
def test_arch_iuse(self, check):
# arch flags must _not_ be in IUSE
- r = self.assertReport(check, self.mk_pkg('x86'))
+ r = self.assertReport(check, self.mk_pkg("x86"))
assert isinstance(r, metadata.UnknownUseFlags)
- assert r.flags == ('x86',)
- assert 'x86' in str(r)
+ assert r.flags == ("x86",)
+ assert "x86" in str(r)
def test_invalid_iuse(self, check):
- for flag in ('+', '-', '@', '_'):
- r = self.assertReport(check, self.mk_pkg(f'foo {flag}'))
+ for flag in ("+", "-", "@", "_"):
+ r = self.assertReport(check, self.mk_pkg(f"foo {flag}"))
assert isinstance(r, metadata.InvalidUseFlags)
assert r.flags == (flag,)
assert flag in str(r)
@@ -331,12 +331,12 @@ class TestEapiCheck(misc.ReportTestCase, misc.Tmpdir):
def mk_check(self, deprecated=(), banned=()):
# TODO: switch to using a repo fixture when available
- os.makedirs(pjoin(self.dir, 'profiles'))
- os.makedirs(pjoin(self.dir, 'metadata'))
- with open(pjoin(self.dir, 'profiles', 'repo_name'), 'w') as f:
- f.write('fake\n')
- with open(pjoin(self.dir, 'metadata', 'layout.conf'), 'w') as f:
- f.write('masters =\n')
+ os.makedirs(pjoin(self.dir, "profiles"))
+ os.makedirs(pjoin(self.dir, "metadata"))
+ with open(pjoin(self.dir, "profiles", "repo_name"), "w") as f:
+ f.write("fake\n")
+ with open(pjoin(self.dir, "metadata", "layout.conf"), "w") as f:
+ f.write("masters =\n")
f.write(f"eapis-deprecated = {' '.join(deprecated)}\n")
f.write(f"eapis-banned = {' '.join(banned)}\n")
repo_config = repo_objs.RepoConfig(location=self.dir)
@@ -345,7 +345,7 @@ class TestEapiCheck(misc.ReportTestCase, misc.Tmpdir):
return self.check_kls(options, eclass_addon=addons.eclass.EclassAddon(options))
def mk_pkg(self, eapi):
- return misc.FakePkg('dev-util/diffball-2.7.1', data={'EAPI': eapi})
+ return misc.FakePkg("dev-util/diffball-2.7.1", data={"EAPI": eapi})
def test_repo_with_no_settings(self):
check = self.mk_check()
@@ -353,29 +353,35 @@ class TestEapiCheck(misc.ReportTestCase, misc.Tmpdir):
self.assertNoReport(check, self.mk_pkg(eapi=eapi_str))
def test_latest_eapi(self):
- check = self.mk_check(deprecated=('0', '2', '4', '5'), banned=('1', '3',))
+ check = self.mk_check(
+ deprecated=("0", "2", "4", "5"),
+ banned=(
+ "1",
+ "3",
+ ),
+ )
latest_eapi = list(eapi.EAPI.known_eapis)[-1]
self.assertNoReport(check, self.mk_pkg(eapi=latest_eapi))
def test_deprecated_eapi(self):
- deprecated = ('0', '2', '4', '5')
- banned = ('1', '3')
+ deprecated = ("0", "2", "4", "5")
+ banned = ("1", "3")
check = self.mk_check(deprecated=deprecated, banned=banned)
for eapi_str in deprecated:
r = self.assertReport(check, self.mk_pkg(eapi=eapi_str))
assert isinstance(r, metadata.DeprecatedEapi)
assert r.eapi == eapi_str
- assert f'uses deprecated EAPI {eapi_str}' in str(r)
+ assert f"uses deprecated EAPI {eapi_str}" in str(r)
def test_banned_eapi(self):
- deprecated = ('0', '2', '4', '5')
- banned = ('1', '3')
+ deprecated = ("0", "2", "4", "5")
+ banned = ("1", "3")
check = self.mk_check(deprecated=deprecated, banned=banned)
for eapi_str in banned:
r = self.assertReport(check, self.mk_pkg(eapi=eapi_str))
assert isinstance(r, metadata.BannedEapi)
assert r.eapi == eapi_str
- assert f'uses banned EAPI {eapi_str}' in str(r)
+ assert f"uses banned EAPI {eapi_str}" in str(r)
class TestSourcingCheck(misc.ReportTestCase, misc.Tmpdir):
@@ -387,19 +393,19 @@ class TestSourcingCheck(misc.ReportTestCase, misc.Tmpdir):
# TODO: switch to using a repo fixture when available
repo_dir = pjoin(self.dir, str(self._repo_id))
self._repo_id += 1
- os.makedirs(pjoin(repo_dir, 'profiles'))
- os.makedirs(pjoin(repo_dir, 'metadata'))
- with open(pjoin(repo_dir, 'profiles', 'repo_name'), 'w') as f:
- f.write('fake\n')
- with open(pjoin(repo_dir, 'metadata', 'layout.conf'), 'w') as f:
- f.write('masters =\n')
+ os.makedirs(pjoin(repo_dir, "profiles"))
+ os.makedirs(pjoin(repo_dir, "metadata"))
+ with open(pjoin(repo_dir, "profiles", "repo_name"), "w") as f:
+ f.write("fake\n")
+ with open(pjoin(repo_dir, "metadata", "layout.conf"), "w") as f:
+ f.write("masters =\n")
repo_config = repo_objs.RepoConfig(location=repo_dir)
self.repo = repository.UnconfiguredTree(repo_config.location, repo_config=repo_config)
options = arghparse.Namespace(target_repo=self.repo, verbosity=False)
return self.check_kls(options)
def mk_pkg(self, eapi):
- return misc.FakePkg('dev-util/diffball-2.7.1', data={'EAPI': eapi})
+ return misc.FakePkg("dev-util/diffball-2.7.1", data={"EAPI": eapi})
def test_repo_with_no_settings(self):
check = self.mk_check()
@@ -407,51 +413,43 @@ class TestSourcingCheck(misc.ReportTestCase, misc.Tmpdir):
self.assertNoReport(check, self.mk_pkg(eapi=eapi_str))
def test_unknown_eapis(self):
- for eapi in ('blah', '9999'):
+ for eapi in ("blah", "9999"):
check = self.mk_check()
- pkg_path = pjoin(self.repo.location, 'dev-util', 'foo')
+ pkg_path = pjoin(self.repo.location, "dev-util", "foo")
os.makedirs(pkg_path)
- with open(pjoin(pkg_path, 'foo-0.ebuild'), 'w') as f:
- f.write(textwrap.dedent(f"""\
- EAPI={eapi}
- """))
+ with open(pjoin(pkg_path, "foo-0.ebuild"), "w") as f:
+ f.write(f"EAPI={eapi}\n")
r = self.assertReport(check, self.repo)
assert isinstance(r, metadata.InvalidEapi)
assert f"EAPI '{eapi}' is not supported" in str(r)
def test_invalid_eapis(self):
- for eapi in ('invalid!', '${EAPI}'):
+ for eapi in ("invalid!", "${EAPI}"):
check = self.mk_check()
- pkg_path = pjoin(self.repo.location, 'dev-util', 'foo')
+ pkg_path = pjoin(self.repo.location, "dev-util", "foo")
os.makedirs(pkg_path)
- with open(pjoin(pkg_path, 'foo-0.ebuild'), 'w') as f:
- f.write(textwrap.dedent(f"""\
- EAPI="{eapi}"
- """))
+ with open(pjoin(pkg_path, "foo-0.ebuild"), "w") as f:
+ f.write(f"EAPI={eapi}\n")
r = self.assertReport(check, self.repo)
assert isinstance(r, metadata.InvalidEapi)
assert f"invalid EAPI '{eapi}'" in str(r)
def test_sourcing_error(self):
check = self.mk_check()
- pkg_path = pjoin(self.repo.location, 'dev-util', 'foo')
+ pkg_path = pjoin(self.repo.location, "dev-util", "foo")
os.makedirs(pkg_path)
- with open(pjoin(pkg_path, 'foo-0.ebuild'), 'w') as f:
- f.write(textwrap.dedent("""\
- foo
- """))
+ with open(pjoin(pkg_path, "foo-0.ebuild"), "w") as f:
+ f.write("foo\n")
r = self.assertReport(check, self.repo)
assert isinstance(r, metadata.SourcingError)
def test_invalid_slots(self):
- for slot in ('?', '0/1'):
+ for slot in ("?", "0/1"):
check = self.mk_check()
- pkg_path = pjoin(self.repo.location, 'dev-util', 'foo')
+ pkg_path = pjoin(self.repo.location, "dev-util", "foo")
os.makedirs(pkg_path)
- with open(pjoin(pkg_path, 'foo-0.ebuild'), 'w') as f:
- f.write(textwrap.dedent(f"""\
- SLOT="{slot}"
- """))
+ with open(pjoin(pkg_path, "foo-0.ebuild"), "w") as f:
+ f.write(f"""SLOT="{slot}"\n""")
r = self.assertReport(check, self.repo)
assert isinstance(r, metadata.InvalidSlot)
assert f"invalid SLOT: '{slot}'" in str(r)
@@ -467,19 +465,26 @@ class TestRequiredUseCheck(IUSE_Options, misc.ReportTestCase):
def mk_check(self, masks=(), verbosity=1, profiles=None):
if profiles is None:
- profiles = {'x86': [misc.FakeProfile(name='default/linux/x86', masks=masks)]}
+ profiles = {"x86": [misc.FakeProfile(name="default/linux/x86", masks=masks)]}
options = self.get_options(verbosity=verbosity)
use_addon = addons.UseAddon(options)
check = self.check_kls(options, use_addon=use_addon, profile_addon=profiles)
return check
- def mk_pkg(self, cpvstr="dev-util/diffball-0.7.1", eapi="4", iuse="",
- required_use="", keywords="~amd64 x86"):
+ def mk_pkg(
+ self,
+ cpvstr="dev-util/diffball-0.7.1",
+ eapi="4",
+ iuse="",
+ required_use="",
+ keywords="~amd64 x86",
+ ):
return FakePkg(
cpvstr,
eapi=eapi,
iuse=iuse.split(),
- data={"REQUIRED_USE": required_use, "KEYWORDS": keywords})
+ data={"REQUIRED_USE": required_use, "KEYWORDS": keywords},
+ )
def test_unsupported_eapis(self, check):
for eapi_str, eapi_obj in eapi.EAPI.known_eapis.items():
@@ -489,9 +494,10 @@ class TestRequiredUseCheck(IUSE_Options, misc.ReportTestCase):
def test_multireport_verbosity(self):
profiles = {
- 'x86': [
- misc.FakeProfile(name='default/linux/x86', masks=()),
- misc.FakeProfile(name='default/linux/x86/foo', masks=())]
+ "x86": [
+ misc.FakeProfile(name="default/linux/x86", masks=()),
+ misc.FakeProfile(name="default/linux/x86/foo", masks=()),
+ ]
}
# non-verbose mode should only one failure per node
check = self.mk_check(verbosity=0, profiles=profiles)
@@ -516,7 +522,9 @@ class TestRequiredUseCheck(IUSE_Options, misc.ReportTestCase):
# only supported in >= EAPI 5
self.assertReport(check, self.mk_pkg(iuse="foo bar", required_use="?? ( foo bar )"))
- self.assertNoReport(check, self.mk_pkg(eapi="5", iuse="foo bar", required_use="?? ( foo bar )"))
+ self.assertNoReport(
+ check, self.mk_pkg(eapi="5", iuse="foo bar", required_use="?? ( foo bar )")
+ )
def test_unstated_iuse(self, check):
r = self.assertReport(check, self.mk_pkg(required_use="foo? ( blah )"))
@@ -534,25 +542,34 @@ class TestRequiredUseCheck(IUSE_Options, misc.ReportTestCase):
# pkgs masked by the related profile aren't checked
self.assertNoReport(
- self.mk_check(masks=('>=dev-util/diffball-8.0',)),
- self.mk_pkg(cpvstr="dev-util/diffball-8.0", iuse="foo bar", required_use="bar"))
+ self.mk_check(masks=(">=dev-util/diffball-8.0",)),
+ self.mk_pkg(cpvstr="dev-util/diffball-8.0", iuse="foo bar", required_use="bar"),
+ )
# unsatisfied REQUIRED_USE
r = self.assertReport(check, self.mk_pkg(iuse="foo bar", required_use="bar"))
assert isinstance(r, metadata.RequiredUseDefaults)
- assert r.keyword == 'x86'
- assert r.profile == 'default/linux/x86'
+ assert r.keyword == "x86"
+ assert r.profile == "default/linux/x86"
assert r.use == ()
- assert str(r.required_use) == 'bar'
+ assert str(r.required_use) == "bar"
# at-most-one-of
- self.assertNoReport(check, self.mk_pkg(eapi="5", iuse="foo bar", required_use="?? ( foo bar )"))
- self.assertNoReport(check, self.mk_pkg(eapi="5", iuse="+foo bar", required_use="?? ( foo bar )"))
- self.assertNoReport(check, self.mk_pkg(eapi="5", iuse="foo +bar", required_use="?? ( foo bar )"))
- r = self.assertReport(check, self.mk_pkg(eapi="5", iuse="+foo +bar", required_use="?? ( foo bar )"))
+ self.assertNoReport(
+ check, self.mk_pkg(eapi="5", iuse="foo bar", required_use="?? ( foo bar )")
+ )
+ self.assertNoReport(
+ check, self.mk_pkg(eapi="5", iuse="+foo bar", required_use="?? ( foo bar )")
+ )
+ self.assertNoReport(
+ check, self.mk_pkg(eapi="5", iuse="foo +bar", required_use="?? ( foo bar )")
+ )
+ r = self.assertReport(
+ check, self.mk_pkg(eapi="5", iuse="+foo +bar", required_use="?? ( foo bar )")
+ )
assert isinstance(r, metadata.RequiredUseDefaults)
- assert r.use == ('bar', 'foo')
- assert str(r.required_use) == 'at-most-one-of ( foo bar )'
+ assert r.use == ("bar", "foo")
+ assert str(r.required_use) == "at-most-one-of ( foo bar )"
# exactly-one-of
self.assertNoReport(check, self.mk_pkg(iuse="+foo bar", required_use="^^ ( foo bar )"))
@@ -560,35 +577,48 @@ class TestRequiredUseCheck(IUSE_Options, misc.ReportTestCase):
self.assertReport(check, self.mk_pkg(iuse="foo bar", required_use="^^ ( foo bar )"))
r = self.assertReport(check, self.mk_pkg(iuse="+foo +bar", required_use="^^ ( foo bar )"))
assert isinstance(r, metadata.RequiredUseDefaults)
- assert r.use == ('bar', 'foo')
- assert str(r.required_use) == 'exactly-one-of ( foo bar )'
+ assert r.use == ("bar", "foo")
+ assert str(r.required_use) == "exactly-one-of ( foo bar )"
# all-of
self.assertNoReport(check, self.mk_pkg(iuse="foo bar baz", required_use="foo? ( bar baz )"))
- self.assertNoReport(check, self.mk_pkg(iuse="+foo +bar +baz", required_use="foo? ( bar baz )"))
+ self.assertNoReport(
+ check, self.mk_pkg(iuse="+foo +bar +baz", required_use="foo? ( bar baz )")
+ )
self.assertReports(check, self.mk_pkg(iuse="+foo bar baz", required_use="foo? ( bar baz )"))
self.assertReport(check, self.mk_pkg(iuse="+foo +bar baz", required_use="foo? ( bar baz )"))
- r = self.assertReport(check, self.mk_pkg(iuse="+foo bar +baz", required_use="foo? ( bar baz )"))
+ r = self.assertReport(
+ check, self.mk_pkg(iuse="+foo bar +baz", required_use="foo? ( bar baz )")
+ )
assert isinstance(r, metadata.RequiredUseDefaults)
- assert r.use == ('baz', 'foo')
+ assert r.use == ("baz", "foo")
# TODO: fix this output to show both required USE flags
- assert str(r.required_use) == 'bar'
+ assert str(r.required_use) == "bar"
# any-of
- self.assertNoReport(check, self.mk_pkg(iuse="foo bar baz", required_use="foo? ( || ( bar baz ) )"))
- self.assertNoReport(check, self.mk_pkg(iuse="+foo +bar baz", required_use="foo? ( || ( bar baz ) )"))
- self.assertNoReport(check, self.mk_pkg(iuse="+foo bar +baz", required_use="foo? ( || ( bar baz ) )"))
- self.assertNoReport(check, self.mk_pkg(iuse="+foo +bar +baz", required_use="foo? ( || ( bar baz ) )"))
- r = self.assertReport(check, self.mk_pkg(iuse="+foo bar baz", required_use="foo? ( || ( bar baz ) )"))
+ self.assertNoReport(
+ check, self.mk_pkg(iuse="foo bar baz", required_use="foo? ( || ( bar baz ) )")
+ )
+ self.assertNoReport(
+ check, self.mk_pkg(iuse="+foo +bar baz", required_use="foo? ( || ( bar baz ) )")
+ )
+ self.assertNoReport(
+ check, self.mk_pkg(iuse="+foo bar +baz", required_use="foo? ( || ( bar baz ) )")
+ )
+ self.assertNoReport(
+ check, self.mk_pkg(iuse="+foo +bar +baz", required_use="foo? ( || ( bar baz ) )")
+ )
+ r = self.assertReport(
+ check, self.mk_pkg(iuse="+foo bar baz", required_use="foo? ( || ( bar baz ) )")
+ )
assert isinstance(r, metadata.RequiredUseDefaults)
- assert r.use == ('foo',)
- assert str(r.required_use) == '( bar || baz )'
+ assert r.use == ("foo",)
+ assert str(r.required_use) == "( bar || baz )"
def use_based():
# hidden to keep the test runner from finding it
class UseBased(IUSE_Options):
-
def test_required_addons(self):
assert addons.UseAddon in self.check_kls.required_addons
@@ -604,30 +634,32 @@ def use_based():
class _TestRestrictPropertiesCheck(use_based(), misc.ReportTestCase):
-
- def mk_pkg(self, restrict='', properties='', iuse=''):
+ def mk_pkg(self, restrict="", properties="", iuse=""):
return misc.FakePkg(
- 'dev-util/diffball-2.7.1',
- data={'IUSE': iuse, 'RESTRICT': restrict, 'PROPERTIES': properties})
+ "dev-util/diffball-2.7.1",
+ data={"IUSE": iuse, "RESTRICT": restrict, "PROPERTIES": properties},
+ )
def test_no_allowed(self):
# repo or its masters don't define any allowed values so anything goes
check = self.mk_check()
- self.assertNoReport(check, self.mk_pkg(**{self.check_kls._attr: 'foo'}))
- self.assertNoReport(check, self.mk_pkg(**{self.check_kls._attr: 'foo? ( bar )', 'iuse': 'foo'}))
+ self.assertNoReport(check, self.mk_pkg(**{self.check_kls._attr: "foo"}))
+ self.assertNoReport(
+ check, self.mk_pkg(**{self.check_kls._attr: "foo? ( bar )", "iuse": "foo"})
+ )
def test_allowed(self):
- check = self.mk_check(options={self.check_kls._attr: ('foo',)})
+ check = self.mk_check(options={self.check_kls._attr: ("foo",)})
# allowed
- self.assertNoReport(check, self.mk_pkg(**{self.check_kls._attr: 'foo'}))
+ self.assertNoReport(check, self.mk_pkg(**{self.check_kls._attr: "foo"}))
# unknown
- r = self.assertReport(check, self.mk_pkg(**{self.check_kls._attr: 'bar'}))
+ r = self.assertReport(check, self.mk_pkg(**{self.check_kls._attr: "bar"}))
assert isinstance(r, self.check_kls._unknown_result_cls)
assert f'unknown {self.check_kls._attr.upper()}="bar"' in str(r)
# unknown multiple, conditional
- pkg = self.mk_pkg(**{self.check_kls._attr: 'baz? ( foo bar boo )', 'iuse': 'baz'})
+ pkg = self.mk_pkg(**{self.check_kls._attr: "baz? ( foo bar boo )", "iuse": "baz"})
r = self.assertReport(check, pkg)
assert isinstance(r, self.check_kls._unknown_result_cls)
assert f'unknown {self.check_kls._attr.upper()}="bar boo"' in str(r)
@@ -635,17 +667,21 @@ class _TestRestrictPropertiesCheck(use_based(), misc.ReportTestCase):
def test_unstated_iuse(self):
check = self.mk_check()
# no IUSE
- self.assertNoReport(check, self.mk_pkg(**{self.check_kls._attr: 'foo'}))
+ self.assertNoReport(check, self.mk_pkg(**{self.check_kls._attr: "foo"}))
# conditional with IUSE defined
- self.assertNoReport(check, self.mk_pkg(**{self.check_kls._attr: 'foo? ( bar )', 'iuse': 'foo'}))
+ self.assertNoReport(
+ check, self.mk_pkg(**{self.check_kls._attr: "foo? ( bar )", "iuse": "foo"})
+ )
# conditional missing IUSE
- r = self.assertReport(check, self.mk_pkg(**{self.check_kls._attr: 'foo? ( bar )'}))
+ r = self.assertReport(check, self.mk_pkg(**{self.check_kls._attr: "foo? ( bar )"}))
assert isinstance(r, addons.UnstatedIuse)
- assert 'unstated flag: [ foo ]' in str(r)
+ assert "unstated flag: [ foo ]" in str(r)
# multiple missing IUSE
- r = self.assertReport(check, self.mk_pkg(**{self.check_kls._attr: 'foo? ( bar ) boo? ( blah )'}))
+ r = self.assertReport(
+ check, self.mk_pkg(**{self.check_kls._attr: "foo? ( bar ) boo? ( blah )"})
+ )
assert isinstance(r, addons.UnstatedIuse)
- assert 'unstated flags: [ boo, foo ]' in str(r)
+ assert "unstated flags: [ boo, foo ]" in str(r)
class TestRestrictCheck(_TestRestrictPropertiesCheck):
@@ -670,30 +706,33 @@ class TestRestrictTestCheck(misc.ReportTestCase):
check_kls = metadata.RestrictTestCheck
check = metadata.RestrictTestCheck(None)
- def mk_pkg(self, iuse='', restrict=''):
- return misc.FakePkg(
- 'dev-util/diffball-2.7.1', data={'IUSE': iuse, 'RESTRICT': restrict})
+ def mk_pkg(self, iuse="", restrict=""):
+ return misc.FakePkg("dev-util/diffball-2.7.1", data={"IUSE": iuse, "RESTRICT": restrict})
def test_empty_restrict(self):
self.assertNoReport(self.check, self.mk_pkg())
def test_specified_restrict(self):
- self.assertNoReport(self.check, self.mk_pkg(
- iuse='test', restrict='!test? ( test )'))
+ self.assertNoReport(self.check, self.mk_pkg(iuse="test", restrict="!test? ( test )"))
# unconditional restriction is fine too
- self.assertNoReport(self.check, self.mk_pkg(iuse='test', restrict='test'))
- self.assertNoReport(self.check, self.mk_pkg(restrict='test'))
+ self.assertNoReport(self.check, self.mk_pkg(iuse="test", restrict="test"))
+ self.assertNoReport(self.check, self.mk_pkg(restrict="test"))
# more RESTRICTs
- self.assertNoReport(self.check, self.mk_pkg(iuse='foo test',
- restrict='foo? ( strip ) !test? ( test ) bindist'))
+ self.assertNoReport(
+ self.check,
+ self.mk_pkg(iuse="foo test", restrict="foo? ( strip ) !test? ( test ) bindist"),
+ )
def test_missing_restrict(self):
data = (
- ('test', ''), # missing entirely
- ('foo test', '!foo? ( test )'), # 'test' present in other condition
- ('foo test', '!foo? ( !test? ( test ) )'), # correct restriction inside another condition
- ('test', 'test? ( test )'), # USE condition gotten the other way around
+ ("test", ""), # missing entirely
+ ("foo test", "!foo? ( test )"), # 'test' present in other condition
+ (
+ "foo test",
+ "!foo? ( !test? ( test ) )",
+ ), # correct restriction inside another condition
+ ("test", "test? ( test )"), # USE condition gotten the other way around
)
for iuse, restrict in data:
r = self.assertReport(self.check, self.mk_pkg(iuse=iuse, restrict=restrict))
@@ -706,67 +745,65 @@ class TestLicenseCheck(use_based(), misc.ReportTestCase):
check_kls = metadata.LicenseCheck
def mk_check(self, licenses=(), **kwargs):
- self.repo = FakeRepo(repo_id='test', licenses=licenses)
+ self.repo = FakeRepo(repo_id="test", licenses=licenses)
options = self.get_options(**kwargs)
use_addon = addons.UseAddon(options)
check = self.check_kls(options, use_addon=use_addon)
return check
- def mk_pkg(self, license='', iuse=''):
+ def mk_pkg(self, license="", iuse=""):
return FakePkg(
- 'dev-util/diffball-2.7.1',
- data={'LICENSE': license, 'IUSE': iuse},
- repo=self.repo)
+ "dev-util/diffball-2.7.1", data={"LICENSE": license, "IUSE": iuse}, repo=self.repo
+ )
def test_malformed(self):
r = self.assertReport(self.mk_check(), self.mk_pkg("|| ("))
assert isinstance(r, metadata.InvalidLicense)
- assert r.attr == 'license'
+ assert r.attr == "license"
def test_empty(self):
r = self.assertReport(self.mk_check(), self.mk_pkg())
assert isinstance(r, metadata.MissingLicense)
def test_unstated_iuse(self):
- chk = self.mk_check(licenses=('BSD',))
+ chk = self.mk_check(licenses=("BSD",))
# no IUSE
- self.assertNoReport(chk, self.mk_pkg('BSD'))
+ self.assertNoReport(chk, self.mk_pkg("BSD"))
# conditional URI with related IUSE
- pkg = self.mk_pkg(license='foo? ( BSD )', iuse='foo')
+ pkg = self.mk_pkg(license="foo? ( BSD )", iuse="foo")
self.assertNoReport(chk, pkg)
# conditional URI with missing IUSE
- pkg = self.mk_pkg(license='foo? ( BSD )')
+ pkg = self.mk_pkg(license="foo? ( BSD )")
r = self.assertReport(chk, pkg)
assert isinstance(r, addons.UnstatedIuse)
- assert 'unstated flag: [ foo ]' in str(r)
+ assert "unstated flag: [ foo ]" in str(r)
def test_single_missing(self):
r = self.assertReport(self.mk_check(), self.mk_pkg("foo"))
assert isinstance(r, metadata.UnknownLicense)
- assert r.licenses == ('foo',)
+ assert r.licenses == ("foo",)
def test_multiple_existing(self):
- chk = self.mk_check(['foo', 'foo2'])
- self.assertNoReport(chk, self.mk_pkg('foo'))
- self.assertNoReport(chk, self.mk_pkg('foo', 'foo2'))
+ chk = self.mk_check(["foo", "foo2"])
+ self.assertNoReport(chk, self.mk_pkg("foo"))
+ self.assertNoReport(chk, self.mk_pkg("foo", "foo2"))
def test_multiple_missing(self):
- chk = self.mk_check(['foo', 'foo2'])
- r = self.assertReport(chk, self.mk_pkg('|| ( foo foo3 foo4 )'))
+ chk = self.mk_check(["foo", "foo2"])
+ r = self.assertReport(chk, self.mk_pkg("|| ( foo foo3 foo4 )"))
assert isinstance(r, metadata.UnknownLicense)
- assert r.licenses == ('foo3', 'foo4')
+ assert r.licenses == ("foo3", "foo4")
def test_unlicensed_categories(self):
- check = self.mk_check(['foo'])
+ check = self.mk_check(["foo"])
for category in self.check_kls.unlicensed_categories:
- for license in ('foo', ''):
+ for license in ("foo", ""):
pkg = FakePkg(
- f'{category}/diffball-2.7.1',
- data={'LICENSE': license},
- repo=self.repo)
+ f"{category}/diffball-2.7.1", data={"LICENSE": license}, repo=self.repo
+ )
if license:
r = self.assertReport(check, pkg)
assert isinstance(r, metadata.UnnecessaryLicense)
@@ -782,87 +819,94 @@ class TestMissingSlotDepCheck(use_based(), misc.ReportTestCase):
def mk_check(self, pkgs=None, **kwargs):
if pkgs is None:
pkgs = (
- FakePkg('dev-libs/foo-0', slot='0'),
- FakePkg('dev-libs/foo-1', slot='1'),
- FakePkg('dev-libs/bar-2', slot='2'),
+ FakePkg("dev-libs/foo-0", slot="0"),
+ FakePkg("dev-libs/foo-1", slot="1"),
+ FakePkg("dev-libs/bar-2", slot="2"),
)
- self.repo = FakeRepo(pkgs=pkgs, repo_id='test')
+ self.repo = FakeRepo(pkgs=pkgs, repo_id="test")
options = self.get_options(**kwargs)
use_addon = addons.UseAddon(options)
check = self.check_kls(options, use_addon=use_addon)
return check
- def mk_pkg(self, eapi='5', rdepend='', depend=''):
+ def mk_pkg(self, eapi="5", rdepend="", depend=""):
return FakePkg(
- 'dev-util/diffball-2.7.1', eapi=eapi,
- data={'RDEPEND': rdepend, 'DEPEND': depend},
- repo=self.repo)
+ "dev-util/diffball-2.7.1",
+ eapi=eapi,
+ data={"RDEPEND": rdepend, "DEPEND": depend},
+ repo=self.repo,
+ )
def test_flagged_deps(self):
- for dep_str in ('dev-libs/foo', 'dev-libs/foo[bar]'):
+ for dep_str in ("dev-libs/foo", "dev-libs/foo[bar]"):
for eapi_str, eapi_obj in eapi.EAPI.known_eapis.items():
if eapi_obj.options.sub_slotting:
r = self.assertReport(
- self.mk_check(), self.mk_pkg(
- eapi=eapi_str, rdepend=dep_str, depend=dep_str))
+ self.mk_check(), self.mk_pkg(eapi=eapi_str, rdepend=dep_str, depend=dep_str)
+ )
assert isinstance(r, metadata.MissingSlotDep)
- assert 'matches more than one slot: [ 0, 1 ]' in str(r)
+ assert "matches more than one slot: [ 0, 1 ]" in str(r)
def test_skipped_deps(self):
for dep_str in (
- '!dev-libs/foo', '!!dev-libs/foo', # blockers
- '~dev-libs/foo-0', '~dev-libs/foo-1', # version limited to single slots
- 'dev-libs/foo:0', 'dev-libs/foo:1', # slotted
- 'dev-libs/foo:*', 'dev-libs/foo:=', # slot operators
- ):
+ "!dev-libs/foo",
+ "!!dev-libs/foo", # blockers
+ "~dev-libs/foo-0",
+ "~dev-libs/foo-1", # version limited to single slots
+ "dev-libs/foo:0",
+ "dev-libs/foo:1", # slotted
+ "dev-libs/foo:*",
+ "dev-libs/foo:=", # slot operators
+ ):
for eapi_str, eapi_obj in eapi.EAPI.known_eapis.items():
if eapi_obj.options.sub_slotting:
self.assertNoReport(
- self.mk_check(), self.mk_pkg(
- eapi=eapi_str, rdepend=dep_str, depend=dep_str))
+ self.mk_check(), self.mk_pkg(eapi=eapi_str, rdepend=dep_str, depend=dep_str)
+ )
def test_no_deps(self):
self.assertNoReport(self.mk_check(), self.mk_pkg())
def test_single_slot_dep(self):
self.assertNoReport(
- self.mk_check(), self.mk_pkg(rdepend='dev-libs/bar', depend='dev-libs/bar'))
+ self.mk_check(), self.mk_pkg(rdepend="dev-libs/bar", depend="dev-libs/bar")
+ )
class TestDependencyCheck(use_based(), misc.ReportTestCase):
check_kls = metadata.DependencyCheck
- def mk_pkg(self, attr, depset='', eapi='0', iuse=''):
- eapi_attr_map = {'BDEPEND': '7', 'IDEPEND': '8'}
+ def mk_pkg(self, attr, depset="", eapi="0", iuse=""):
+ eapi_attr_map = {"BDEPEND": "7", "IDEPEND": "8"}
eapi = eapi_attr_map.get(attr, eapi)
return misc.FakePkg(
- 'dev-util/diffball-2.7.1',
- data={'EAPI': eapi, 'IUSE': iuse, attr: depset})
+ "dev-util/diffball-2.7.1", data={"EAPI": eapi, "IUSE": iuse, attr: depset}
+ )
def mk_check(self, pkgs=None, **kwargs):
if pkgs is None:
pkgs = (
- FakePkg('dev-libs/foo-0', slot='0', iuse=('bar',)),
- FakePkg('dev-libs/foo-1', slot='1', iuse=('bar', 'baz')),
- FakePkg('dev-libs/bar-2', slot='2'),
+ FakePkg("dev-libs/foo-0", slot="0", iuse=("bar",)),
+ FakePkg("dev-libs/foo-1", slot="1", iuse=("bar", "baz")),
+ FakePkg("dev-libs/bar-2", slot="2"),
)
- kwargs['search_repo'] = FakeRepo(pkgs=pkgs, repo_id='test')
+ kwargs["search_repo"] = FakeRepo(pkgs=pkgs, repo_id="test")
return super().mk_check(options=kwargs)
# pull the set of dependency attrs from the most recent EAPI
dep_attrs = sorted(list(eapi.EAPI.known_eapis.values())[-1].dep_keys)
- @pytest.mark.parametrize('attr', dep_attrs)
+ @pytest.mark.parametrize("attr", dep_attrs)
def test_depset(self, attr):
chk = self.mk_check()
mk_pkg = partial(self.mk_pkg, attr)
# various regular depsets
self.assertNoReport(chk, mk_pkg())
- self.assertNoReport(chk, mk_pkg('dev-util/foo'))
+ self.assertNoReport(chk, mk_pkg("dev-util/foo"))
self.assertNoReport(chk, mk_pkg("|| ( dev-util/foo ) dev-foo/bugger "))
- if attr == 'RDEPEND':
+ if attr == "RDEPEND":
self.assertNoReport(chk, mk_pkg("!dev-util/blah"))
else:
r = self.assertReport(chk, mk_pkg("!dev-util/blah"))
@@ -870,7 +914,7 @@ class TestDependencyCheck(use_based(), misc.ReportTestCase):
# invalid depset syntax
r = self.assertReport(chk, mk_pkg("|| ("))
- assert isinstance(r, getattr(metadata, f'Invalid{attr.lower().capitalize()}'))
+ assert isinstance(r, getattr(metadata, f"Invalid{attr.lower().capitalize()}"))
# pkg blocking itself
r = self.assertReport(chk, mk_pkg("!dev-util/diffball"))
@@ -879,105 +923,113 @@ class TestDependencyCheck(use_based(), misc.ReportTestCase):
assert f'{attr.upper()}="!dev-util/diffball"' in str(r)
# check for := in || () blocks
- pkg = mk_pkg(eapi='5', depset="|| ( dev-libs/foo:= dev-libs/bar )")
+ pkg = mk_pkg(eapi="5", depset="|| ( dev-libs/foo:= dev-libs/bar )")
r = self.assertReport(chk, pkg)
assert isinstance(r, metadata.BadDependency)
assert "= slot operator used inside || block" in str(r)
assert f'{attr.upper()}="dev-libs/foo:="' in str(r)
# multiple := atoms in || () blocks
- pkg = mk_pkg(eapi='5', depset="|| ( dev-libs/foo:= dev-libs/bar:= )")
+ pkg = mk_pkg(eapi="5", depset="|| ( dev-libs/foo:= dev-libs/bar:= )")
reports = self.assertReports(chk, pkg)
for r in reports:
assert isinstance(r, metadata.BadDependency)
assert "= slot operator used inside || block" in str(r)
# check for := in blockers
- r = self.assertReport(chk, mk_pkg(eapi='5', depset="!dev-libs/foo:="))
+ r = self.assertReport(chk, mk_pkg(eapi="5", depset="!dev-libs/foo:="))
assert isinstance(r, metadata.BadDependency)
assert "= slot operator used in blocker" in str(r)
assert f'{attr.upper()}="!dev-libs/foo:="' in str(r)
# check for missing package revisions
self.assertNoReport(chk, mk_pkg("=dev-libs/foo-1-r0"))
- r = self.assertReport(chk, mk_pkg(eapi='6', depset="=dev-libs/foo-1"))
+ r = self.assertReport(chk, mk_pkg(eapi="6", depset="=dev-libs/foo-1"))
assert isinstance(r, metadata.MissingPackageRevision)
assert f'{attr.upper()}="=dev-libs/foo-1"' in str(r)
- @pytest.mark.parametrize('attr', dep_attrs)
+ @pytest.mark.parametrize("attr", dep_attrs)
def test_depset_unstated_iuse(self, attr):
chk = self.mk_check()
mk_pkg = partial(self.mk_pkg, attr)
# unstated IUSE
- r = self.assertReport(chk, mk_pkg(depset='foo? ( dev-libs/foo )'))
+ r = self.assertReport(chk, mk_pkg(depset="foo? ( dev-libs/foo )"))
assert isinstance(r, addons.UnstatedIuse)
- assert 'unstated flag: [ foo ]' in str(r)
+ assert "unstated flag: [ foo ]" in str(r)
# known IUSE
- self.assertNoReport(chk, mk_pkg(depset='foo? ( dev-libs/foo )', iuse='foo'))
+ self.assertNoReport(chk, mk_pkg(depset="foo? ( dev-libs/foo )", iuse="foo"))
# multiple unstated IUSE
- r = self.assertReport(chk, mk_pkg(depset='foo? ( !bar? ( dev-libs/foo ) )'))
+ r = self.assertReport(chk, mk_pkg(depset="foo? ( !bar? ( dev-libs/foo ) )"))
assert isinstance(r, addons.UnstatedIuse)
- assert 'unstated flags: [ bar, foo ]' in str(r)
+ assert "unstated flags: [ bar, foo ]" in str(r)
- @pytest.mark.parametrize('attr', dep_attrs)
+ @pytest.mark.parametrize("attr", dep_attrs)
def test_depset_missing_usedep_default(self, attr):
chk = self.mk_check()
mk_pkg = partial(self.mk_pkg, attr)
# USE flag exists on all matching pkgs
- self.assertNoReport(chk, mk_pkg(eapi='4', depset='dev-libs/foo[bar?]'))
+ self.assertNoReport(chk, mk_pkg(eapi="4", depset="dev-libs/foo[bar?]"))
use_deps = (
- 'foo(-)?', '!foo(-)?', 'foo(+)?', '!foo(+)?', 'foo(-)=', '!foo(-)=',
- 'foo(+)=', '!foo(+)=', '-foo(-)', '-foo(+)',
+ "foo(-)?",
+ "!foo(-)?",
+ "foo(+)?",
+ "!foo(+)?",
+ "foo(-)=",
+ "!foo(-)=",
+ "foo(+)=",
+ "!foo(+)=",
+ "-foo(-)",
+ "-foo(+)",
)
for use_dep in use_deps:
# USE flag doesn't exist but has proper default
- self.assertNoReport(chk, mk_pkg(eapi='4', depset=f'dev-libs/bar[{use_dep}]'))
- if attr == 'RDEPEND':
- self.assertNoReport(chk, mk_pkg(eapi='4', depset=f'!dev-libs/bar[{use_dep}]'))
+ self.assertNoReport(chk, mk_pkg(eapi="4", depset=f"dev-libs/bar[{use_dep}]"))
+ if attr == "RDEPEND":
+ self.assertNoReport(chk, mk_pkg(eapi="4", depset=f"!dev-libs/bar[{use_dep}]"))
else:
- r = self.assertReport(chk, mk_pkg(eapi='4', depset=f'!dev-libs/bar[{use_dep}]'))
+ r = self.assertReport(chk, mk_pkg(eapi="4", depset=f"!dev-libs/bar[{use_dep}]"))
assert isinstance(r, metadata.MisplacedWeakBlocker)
# result triggers when all matching pkgs don't have requested USE flag
for dep in (
- 'dev-libs/bar[foo?]',
- 'dev-libs/bar[!foo?]',
- 'dev-libs/bar[foo=]',
- 'dev-libs/bar[!foo=]',
- 'dev-libs/bar[-foo]',
- '|| ( dev-libs/foo[bar] dev-libs/bar[foo] )',
- '|| ( dev-libs/foo[bar] dev-libs/bar[-foo] )',
- ):
- r = self.assertReport(chk, mk_pkg(eapi='4', depset=dep))
+ "dev-libs/bar[foo?]",
+ "dev-libs/bar[!foo?]",
+ "dev-libs/bar[foo=]",
+ "dev-libs/bar[!foo=]",
+ "dev-libs/bar[-foo]",
+ "|| ( dev-libs/foo[bar] dev-libs/bar[foo] )",
+ "|| ( dev-libs/foo[bar] dev-libs/bar[-foo] )",
+ ):
+ r = self.assertReport(chk, mk_pkg(eapi="4", depset=dep))
assert isinstance(r, metadata.MissingUseDepDefault)
- assert r.pkgs == ('dev-libs/bar-2',)
- assert r.flag == 'foo'
+ assert r.pkgs == ("dev-libs/bar-2",)
+ assert r.flag == "foo"
assert "USE flag 'foo' missing" in str(r)
- if attr == 'RDEPEND':
- r = self.assertReport(chk, mk_pkg(eapi='4', depset='!dev-libs/bar[foo?]'))
+ if attr == "RDEPEND":
+ r = self.assertReport(chk, mk_pkg(eapi="4", depset="!dev-libs/bar[foo?]"))
assert isinstance(r, metadata.MissingUseDepDefault)
- assert r.pkgs == ('dev-libs/bar-2',)
- assert r.flag == 'foo'
+ assert r.pkgs == ("dev-libs/bar-2",)
+ assert r.flag == "foo"
assert "USE flag 'foo' missing" in str(r)
# USE flag missing on one of multiple matches
- r = self.assertReport(chk, mk_pkg(eapi='4', depset='dev-libs/foo[baz?]'))
+ r = self.assertReport(chk, mk_pkg(eapi="4", depset="dev-libs/foo[baz?]"))
assert isinstance(r, metadata.MissingUseDepDefault)
- assert r.atom == 'dev-libs/foo[baz?]'
- assert r.pkgs == ('dev-libs/foo-0',)
- assert r.flag == 'baz'
+ assert r.atom == "dev-libs/foo[baz?]"
+ assert r.pkgs == ("dev-libs/foo-0",)
+ assert r.flag == "baz"
assert "USE flag 'baz' missing" in str(r)
# USE flag missing on all matches
- r = self.assertReport(chk, mk_pkg(eapi='4', depset='dev-libs/foo[blah?]'))
+ r = self.assertReport(chk, mk_pkg(eapi="4", depset="dev-libs/foo[blah?]"))
assert isinstance(r, metadata.MissingUseDepDefault)
- assert r.atom == 'dev-libs/foo[blah?]'
- assert r.pkgs == ('dev-libs/foo-0', 'dev-libs/foo-1')
- assert r.flag == 'blah'
+ assert r.atom == "dev-libs/foo[blah?]"
+ assert r.pkgs == ("dev-libs/foo-0", "dev-libs/foo-1")
+ assert r.flag == "blah"
assert "USE flag 'blah' missing" in str(r)
@@ -993,16 +1045,16 @@ class TestOutdatedBlockersCheck(misc.ReportTestCase):
# initialize parent repo
self.parent_git_repo = make_git_repo()
self.parent_repo = make_repo(self.parent_git_repo.path)
- self.parent_git_repo.add_all('initial commit')
+ self.parent_git_repo.add_all("initial commit")
# create a stub pkg and commit it
- self.parent_repo.create_ebuild('cat/pkg-0')
- self.parent_git_repo.add_all('cat/pkg-0')
+ self.parent_repo.create_ebuild("cat/pkg-0")
+ self.parent_git_repo.add_all("cat/pkg-0")
# initialize child repo
self.child_git_repo = make_git_repo()
- self.child_git_repo.run(['git', 'remote', 'add', 'origin', self.parent_git_repo.path])
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_git_repo.run(['git', 'remote', 'set-head', 'origin', 'main'])
+ self.child_git_repo.run(["git", "remote", "add", "origin", self.parent_git_repo.path])
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_git_repo.run(["git", "remote", "set-head", "origin", "main"])
self.child_repo = make_repo(self.child_git_repo.path)
def init_check(self, options=None, future=0):
@@ -1015,36 +1067,39 @@ class TestOutdatedBlockersCheck(misc.ReportTestCase):
def _options(self, **kwargs):
args = [
- 'scan', '-q', '--cache-dir', self.cache_dir,
- '--repo', self.child_repo.location,
+ "scan",
+ "-q",
+ "--cache-dir",
+ self.cache_dir,
+ "--repo",
+ self.child_repo.location,
]
options, _ = self.tool.parse_args(args)
return options
def test_existent_blockers(self):
- self.child_repo.create_ebuild('cat/pkg-1', depend='!~cat/pkg-0')
- self.child_git_repo.add_all('cat/pkg: version bump to 1')
- self.child_repo.create_ebuild('cat/pkg-2', depend='!!~cat/pkg-0')
- self.child_git_repo.add_all('cat/pkg: version bump to 2')
- self.child_repo.create_ebuild('cat/pkg-3', depend='!!=cat/pkg-0*')
- self.child_git_repo.add_all('cat/pkg: version bump to 3')
+ self.child_repo.create_ebuild("cat/pkg-1", depend="!~cat/pkg-0")
+ self.child_git_repo.add_all("cat/pkg: version bump to 1")
+ self.child_repo.create_ebuild("cat/pkg-2", depend="!!~cat/pkg-0")
+ self.child_git_repo.add_all("cat/pkg: version bump to 2")
+ self.child_repo.create_ebuild("cat/pkg-3", depend="!!=cat/pkg-0*")
+ self.child_git_repo.add_all("cat/pkg: version bump to 3")
self.init_check()
self.assertNoReport(self.check, self.source)
def test_nonexistent_blockers(self):
- self.child_repo.create_ebuild('cat/pkg-1', depend='!nonexistent/pkg')
- self.child_git_repo.add_all('cat/pkg: version bump to 1')
+ self.child_repo.create_ebuild("cat/pkg-1", depend="!nonexistent/pkg")
+ self.child_git_repo.add_all("cat/pkg: version bump to 1")
self.init_check()
r = self.assertReport(self.check, self.source)
- expected = metadata.NonexistentBlocker(
- 'DEPEND', '!nonexistent/pkg', pkg=CPV('cat/pkg-1'))
+ expected = metadata.NonexistentBlocker("DEPEND", "!nonexistent/pkg", pkg=CPV("cat/pkg-1"))
assert r == expected
def test_outdated_blockers(self):
- self.parent_git_repo.remove_all('cat/pkg')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_repo.create_ebuild('cat/pkg-1', depend='!!=cat/pkg-0*')
- self.child_git_repo.add_all('cat/pkg: version bump to 1')
+ self.parent_git_repo.remove_all("cat/pkg")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_repo.create_ebuild("cat/pkg-1", depend="!!=cat/pkg-0*")
+ self.child_git_repo.add_all("cat/pkg: version bump to 1")
# packages are not old enough to trigger any results
for days in (0, 100, 365, 729):
@@ -1056,7 +1111,8 @@ class TestOutdatedBlockersCheck(misc.ReportTestCase):
self.init_check(future=days)
r = self.assertReport(self.check, self.source)
expected = metadata.OutdatedBlocker(
- 'DEPEND', '!!=cat/pkg-0*', years, pkg=CPV('cat/pkg-1'))
+ "DEPEND", "!!=cat/pkg-0*", years, pkg=CPV("cat/pkg-1")
+ )
assert r == expected
@@ -1064,16 +1120,17 @@ class TestSrcUriCheck(use_based(), misc.ReportTestCase):
check_kls = metadata.SrcUriCheck
- def mk_pkg(self, src_uri='', restrict='', default_chksums={"size": 100},
- iuse='', disable_chksums=False):
+ def mk_pkg(
+ self, src_uri="", restrict="", default_chksums={"size": 100}, iuse="", disable_chksums=False
+ ):
class fake_repo:
def __init__(self, default_chksums):
if disable_chksums:
self.chksums = {}
else:
self.chksums = {}.fromkeys(
- {os.path.basename(x) for x in src_uri.split()},
- default_chksums)
+ {os.path.basename(x) for x in src_uri.split()}, default_chksums
+ )
def _get_digests(self, pkg, allow_missing=False):
return False, self.chksums
@@ -1082,47 +1139,52 @@ class TestSrcUriCheck(use_based(), misc.ReportTestCase):
_parent_repo = fake_repo(default_chksums)
return misc.FakePkg(
- 'dev-util/diffball-2.7.1',
- data={'SRC_URI': src_uri, 'IUSE': iuse, 'RESTRICT': restrict},
- parent=fake_parent())
+ "dev-util/diffball-2.7.1",
+ data={"SRC_URI": src_uri, "IUSE": iuse, "RESTRICT": restrict},
+ parent=fake_parent(),
+ )
def test_malformed(self):
- r = self.assertReport(
- self.mk_check(), self.mk_pkg("foon", disable_chksums=True))
+ r = self.assertReport(self.mk_check(), self.mk_pkg("foon", disable_chksums=True))
assert isinstance(r, metadata.InvalidSrcUri)
- assert r.attr == 'fetchables'
+ assert r.attr == "fetchables"
def test_regular_src_uri(self):
chk = self.mk_check()
# single file
- self.assertNoReport(chk, self.mk_pkg(src_uri='https://foon.com/foon-2.7.1.tar.gz'))
+ self.assertNoReport(chk, self.mk_pkg(src_uri="https://foon.com/foon-2.7.1.tar.gz"))
# single file, multiple uris
- self.assertNoReport(chk, self.mk_pkg(
- src_uri='https://foo.com/a-0.tar.gz https://bar.com/a-0.tar.gz'))
+ self.assertNoReport(
+ chk, self.mk_pkg(src_uri="https://foo.com/a-0.tar.gz https://bar.com/a-0.tar.gz")
+ )
# multiple files, multiple uris
- self.assertNoReport(chk, self.mk_pkg(
- src_uri="""
+ self.assertNoReport(
+ chk,
+ self.mk_pkg(
+ src_uri="""
https://foo.com/a-0.tar.gz https://bar.com/a-0.tar.gz
https://blah.org/b-1.zip https://boo.net/boo-10.tar.xz
- """))
+ """
+ ),
+ )
def test_unknown_mirror(self):
chk = self.mk_check()
# single mirror
- r = self.assertReport(chk, self.mk_pkg('mirror://foo/a-0.gz https://foo.com/a-0.gz'))
+ r = self.assertReport(chk, self.mk_pkg("mirror://foo/a-0.gz https://foo.com/a-0.gz"))
assert isinstance(r, metadata.UnknownMirror)
- assert r.mirror == 'foo'
- assert r.uri == 'mirror://foo/a-0.gz'
+ assert r.mirror == "foo"
+ assert r.uri == "mirror://foo/a-0.gz"
assert "unknown mirror 'foo'" in str(r)
# multiple mirrors
- pkg = self.mk_pkg('mirror://foo/a-0.gz mirror://bar/a-0.gz https://foo.com/a-0.gz')
+ pkg = self.mk_pkg("mirror://foo/a-0.gz mirror://bar/a-0.gz https://foo.com/a-0.gz")
reports = self.assertReports(chk, pkg)
- for mirror, r in zip(('bar', 'foo'), sorted(reports, key=attrgetter('mirror'))):
+ for mirror, r in zip(("bar", "foo"), sorted(reports, key=attrgetter("mirror"))):
assert isinstance(r, metadata.UnknownMirror)
assert r.mirror == mirror
- assert r.uri == f'mirror://{mirror}/a-0.gz'
+ assert r.uri == f"mirror://{mirror}/a-0.gz"
assert f"unknown mirror '{mirror}'" in str(r)
def test_bad_filename(self):
@@ -1131,77 +1193,80 @@ class TestSrcUriCheck(use_based(), misc.ReportTestCase):
# PN filename
r = self.assertReport(chk, self.mk_pkg("https://foon.com/diffball.tar.gz"))
assert isinstance(r, metadata.BadFilename)
- assert r.filenames == ('diffball.tar.gz',)
- assert 'bad filename: [ diffball.tar.gz ]' in str(r)
+ assert r.filenames == ("diffball.tar.gz",)
+ assert "bad filename: [ diffball.tar.gz ]" in str(r)
# PV filename
r = self.assertReport(chk, self.mk_pkg("https://foon.com/2.7.1.tar.gz"))
assert isinstance(r, metadata.BadFilename)
- assert r.filenames == ('2.7.1.tar.gz',)
- assert 'bad filename: [ 2.7.1.tar.gz ]' in str(r)
+ assert r.filenames == ("2.7.1.tar.gz",)
+ assert "bad filename: [ 2.7.1.tar.gz ]" in str(r)
# github-style PV filename
r = self.assertReport(chk, self.mk_pkg("https://foon.com/v2.7.1.zip"))
assert isinstance(r, metadata.BadFilename)
- assert r.filenames == ('v2.7.1.zip',)
- assert 'bad filename: [ v2.7.1.zip ]' in str(r)
+ assert r.filenames == ("v2.7.1.zip",)
+ assert "bad filename: [ v2.7.1.zip ]" in str(r)
# github-style commit snapshot filename
- r = self.assertReport(chk, self.mk_pkg("https://foon.com/cb230f01fb288a0b9f0fc437545b97d06c846bd3.tar.gz"))
+ r = self.assertReport(
+ chk, self.mk_pkg("https://foon.com/cb230f01fb288a0b9f0fc437545b97d06c846bd3.tar.gz")
+ )
assert isinstance(r, metadata.BadFilename)
# multiple bad filenames
- r = self.assertReport(chk, self.mk_pkg("https://foon.com/2.7.1.tar.gz https://foon.com/diffball.zip"))
+ r = self.assertReport(
+ chk, self.mk_pkg("https://foon.com/2.7.1.tar.gz https://foon.com/diffball.zip")
+ )
assert isinstance(r, metadata.BadFilename)
- assert r.filenames == ('2.7.1.tar.gz', 'diffball.zip')
- assert 'bad filenames: [ 2.7.1.tar.gz, diffball.zip ]' in str(r)
+ assert r.filenames == ("2.7.1.tar.gz", "diffball.zip")
+ assert "bad filenames: [ 2.7.1.tar.gz, diffball.zip ]" in str(r)
def test_missing_uri(self):
chk = self.mk_check()
# mangled protocol
- r = self.assertReport(chk, self.mk_pkg('http:/foo/foo-0.tar.gz'))
+ r = self.assertReport(chk, self.mk_pkg("http:/foo/foo-0.tar.gz"))
assert isinstance(r, metadata.MissingUri)
- assert r.filenames == ('http:/foo/foo-0.tar.gz',)
+ assert r.filenames == ("http:/foo/foo-0.tar.gz",)
assert "unfetchable file: 'http:/foo/foo-0.tar.gz'" in str(r)
# no URI and RESTRICT doesn't contain 'fetch'
- r = self.assertReport(chk, self.mk_pkg('foon'))
+ r = self.assertReport(chk, self.mk_pkg("foon"))
assert isinstance(r, metadata.MissingUri)
- assert r.filenames == ('foon',)
+ assert r.filenames == ("foon",)
assert "unfetchable file: 'foon'" in str(r)
# no URI and RESTRICT contains 'fetch'
- self.assertNoReport(chk, self.mk_pkg('foon', restrict='fetch'))
+ self.assertNoReport(chk, self.mk_pkg("foon", restrict="fetch"))
# conditional URI and conditional RESTRICT containing 'fetch'
- pkg = self.mk_pkg(src_uri='foo? ( bar )', iuse='foo', restrict='foo? ( fetch )')
+ pkg = self.mk_pkg(src_uri="foo? ( bar )", iuse="foo", restrict="foo? ( fetch )")
self.assertNoReport(chk, pkg)
# negated
- pkg = self.mk_pkg(src_uri='!foo? ( bar )', iuse='foo', restrict='!foo? ( fetch )')
+ pkg = self.mk_pkg(src_uri="!foo? ( bar )", iuse="foo", restrict="!foo? ( fetch )")
self.assertNoReport(chk, pkg)
# multi-level conditional
pkg = self.mk_pkg(
- iuse='foo bar',
- src_uri='foo? ( bar? ( blah ) )',
- restrict='foo? ( bar? ( fetch ) )')
+ iuse="foo bar", src_uri="foo? ( bar? ( blah ) )", restrict="foo? ( bar? ( fetch ) )"
+ )
self.assertNoReport(chk, pkg)
def test_unstated_iuse(self):
chk = self.mk_check()
# no IUSE
- self.assertNoReport(chk, self.mk_pkg('https://foo.com/foo-0.tar.gz'))
+ self.assertNoReport(chk, self.mk_pkg("https://foo.com/foo-0.tar.gz"))
# conditional URI with related IUSE
- pkg = self.mk_pkg(src_uri='foo? ( https://foo.com/foo-0.tar.gz )', iuse='foo')
+ pkg = self.mk_pkg(src_uri="foo? ( https://foo.com/foo-0.tar.gz )", iuse="foo")
self.assertNoReport(chk, pkg)
# conditional URI with missing IUSE
- pkg = self.mk_pkg(src_uri='foo? ( https://foo.com/foo-0.tar.gz )')
+ pkg = self.mk_pkg(src_uri="foo? ( https://foo.com/foo-0.tar.gz )")
r = self.assertReport(chk, pkg)
assert isinstance(r, addons.UnstatedIuse)
- assert 'unstated flag: [ foo ]' in str(r)
+ assert "unstated flag: [ foo ]" in str(r)
def test_bad_proto(self):
chk = self.mk_check()
@@ -1211,22 +1276,23 @@ class TestSrcUriCheck(use_based(), misc.ReportTestCase):
for proto in self.check_kls.valid_protos:
self.assertNoReport(
- chk, self.mk_pkg(f"{proto}://dar.com/foon"),
- msg=f"testing valid proto {proto}")
+ chk, self.mk_pkg(f"{proto}://dar.com/foon"), msg=f"testing valid proto {proto}"
+ )
- bad_proto = f'{proto}x'
+ bad_proto = f"{proto}x"
r = self.assertReport(chk, self.mk_pkg(f"{bad_proto}://foon.com/foon"))
assert isinstance(r, metadata.BadProtocol)
assert bad_proto in str(r)
- assert f'{bad_proto}://foon.com/foon' in str(r)
+ assert f"{bad_proto}://foon.com/foon" in str(r)
# check collapsing
pkg = self.mk_pkg(f"{bad_proto}://foon.com/foon {bad_proto}://dar.com/foon")
r = self.assertReport(chk, pkg)
assert isinstance(r, metadata.BadProtocol)
assert list(r.uris) == sorted(
- f'{bad_proto}://{x}/foon' for x in ('foon.com', 'dar.com'))
+ f"{bad_proto}://{x}/foon" for x in ("foon.com", "dar.com")
+ )
assert bad_proto in str(r)
def test_tarball_available_github(self):
@@ -1235,7 +1301,7 @@ class TestSrcUriCheck(use_based(), misc.ReportTestCase):
r = self.assertReport(chk, self.mk_pkg(uri))
assert isinstance(r, metadata.TarballAvailable)
assert r.uris == (uri,)
- assert '[ https://github.com/foo/bar/archive/v1.2.3.zip ]' in str(r)
+ assert "[ https://github.com/foo/bar/archive/v1.2.3.zip ]" in str(r)
def test_tarball_available_gitlab(self):
chk = self.mk_check()
@@ -1243,36 +1309,34 @@ class TestSrcUriCheck(use_based(), misc.ReportTestCase):
r = self.assertReport(chk, self.mk_pkg(uri))
assert isinstance(r, metadata.TarballAvailable)
assert r.uris == (uri,)
- assert 'zip archive used when tarball available' in str(r)
+ assert "zip archive used when tarball available" in str(r)
class TestMissingUnpackerDepCheck(use_based(), misc.ReportTestCase):
check_kls = metadata.MissingUnpackerDepCheck
- def mk_pkg(self, exts, eapi='7', **data):
+ def mk_pkg(self, exts, eapi="7", **data):
if isinstance(exts, str):
exts = [exts]
class fake_repo:
def _get_digests(self, pkg, allow_missing=False):
- chksums = {f'diffball-2.7.1{ext}': {'size': 100} for ext in exts}
+ chksums = {f"diffball-2.7.1{ext}": {"size": 100} for ext in exts}
return False, chksums
- data['SRC_URI'] = ' '.join(
- f'https://foo.com/diffball-2.7.1{ext}' for ext in exts)
- return FakePkg(
- 'dev-util/diffball-2.7.1', data=data, eapi=eapi, repo=fake_repo())
+ data["SRC_URI"] = " ".join(f"https://foo.com/diffball-2.7.1{ext}" for ext in exts)
+ return FakePkg("dev-util/diffball-2.7.1", data=data, eapi=eapi, repo=fake_repo())
def test_with_system_dep(self):
- self.assertNoReport(self.mk_check(), self.mk_pkg('.tar.gz'))
+ self.assertNoReport(self.mk_check(), self.mk_pkg(".tar.gz"))
def test_keyword_output(self):
# unpacker deps go in BDEPEND in EAPI >= 7
- r = self.assertReport(self.mk_check(), self.mk_pkg('.zip', eapi='7'))
+ r = self.assertReport(self.mk_check(), self.mk_pkg(".zip", eapi="7"))
assert 'missing BDEPEND="app-arch/unzip"' in str(r)
# and in DEPEND for EAPI < 7
- r = self.assertReport(self.mk_check(), self.mk_pkg('.zip', eapi='6'))
+ r = self.assertReport(self.mk_check(), self.mk_pkg(".zip", eapi="6"))
assert 'missing DEPEND="app-arch/unzip"' in str(r)
def test_without_dep(self):
@@ -1280,23 +1344,22 @@ class TestMissingUnpackerDepCheck(use_based(), misc.ReportTestCase):
pkg = self.mk_pkg(ext)
r = self.assertReport(self.mk_check(), pkg)
assert isinstance(r, metadata.MissingUnpackerDep)
- assert r.filenames == (f'diffball-2.7.1{ext}',)
- assert r.unpackers == tuple(
- sorted(map(str, self.check_kls.non_system_unpackers[ext])))
+ assert r.filenames == (f"diffball-2.7.1{ext}",)
+ assert r.unpackers == tuple(sorted(map(str, self.check_kls.non_system_unpackers[ext])))
def test_with_dep(self):
for ext, unpackers in self.check_kls.non_system_unpackers.items():
- for dep_type in ('DEPEND', 'BDEPEND'):
+ for dep_type in ("DEPEND", "BDEPEND"):
for unpacker in unpackers:
- for dep in (unpacker, f'>={unpacker}-1'):
+ for dep in (unpacker, f">={unpacker}-1"):
kwargs = {dep_type: dep}
pkg = self.mk_pkg(ext, **kwargs)
self.assertNoReport(self.mk_check(), pkg)
def test_rar_with_or_dep(self):
self.assertNoReport(
- self.mk_check(),
- self.mk_pkg('.rar', DEPEND='|| ( app-arch/rar app-arch/unrar )'))
+ self.mk_check(), self.mk_pkg(".rar", DEPEND="|| ( app-arch/rar app-arch/unrar )")
+ )
def test_without_multiple_unpackers(self):
for combination in combinations(self.check_kls.non_system_unpackers.items(), 2):
@@ -1310,19 +1373,19 @@ class TestMissingUnpackerDepCheck(use_based(), misc.ReportTestCase):
assert len(set(unpackers)) == 1
r = reports[0]
assert isinstance(r, metadata.MissingUnpackerDep)
- assert r.filenames == tuple(sorted(f'diffball-2.7.1{ext}' for ext in exts))
+ assert r.filenames == tuple(sorted(f"diffball-2.7.1{ext}" for ext in exts))
assert r.unpackers == tuple(sorted(map(str, unpackers[0])))
else:
assert len(reports) == 2
for i, r in enumerate(reports):
assert isinstance(r, metadata.MissingUnpackerDep)
- assert r.filenames == (f'diffball-2.7.1{exts[i]}',)
+ assert r.filenames == (f"diffball-2.7.1{exts[i]}",)
assert r.unpackers == tuple(sorted(map(str, unpackers[i])))
def test_with_multiple_unpackers_one_missing(self):
r = self.assertReport(
- self.mk_check(),
- self.mk_pkg(['.zip', '.7z'], DEPEND='app-arch/unzip'))
+ self.mk_check(), self.mk_pkg([".zip", ".7z"], DEPEND="app-arch/unzip")
+ )
assert isinstance(r, metadata.MissingUnpackerDep)
- assert r.filenames == (f'diffball-2.7.1.7z',)
- assert r.unpackers == ('app-arch/p7zip',)
+ assert r.filenames == (f"diffball-2.7.1.7z",)
+ assert r.unpackers == ("app-arch/p7zip",)
diff --git a/tests/checks/test_network.py b/tests/checks/test_network.py
index bb3a7ef5..fb684954 100644
--- a/tests/checks/test_network.py
+++ b/tests/checks/test_network.py
@@ -10,34 +10,38 @@ from unittest.mock import patch
import pytest
from pkgcheck import objects, reporters, scan
from pkgcheck.checks import NetworkCheck
-from pkgcheck.checks.network import (DeadUrl, FetchablesUrlCheck,
- HomepageUrlCheck)
+from pkgcheck.checks.network import DeadUrl, FetchablesUrlCheck, HomepageUrlCheck
from pkgcheck.packages import RawCPV
from snakeoil.formatters import PlainTextFormatter
# skip module tests if requests isn't available
-requests = pytest.importorskip('requests')
+requests = pytest.importorskip("requests")
class TestNetworkChecks:
- repos_data = pytest.REPO_ROOT / 'testdata/data/repos'
- repos_dir = pytest.REPO_ROOT / 'testdata/repos'
+ repos_data = pytest.REPO_ROOT / "testdata/data/repos"
+ repos_dir = pytest.REPO_ROOT / "testdata/repos"
@pytest.fixture(autouse=True)
def _setup(self, testconfig, tmp_path):
- base_args = ['--config', testconfig]
+ base_args = ["--config", testconfig]
self.scan = partial(scan, base_args=base_args)
self.scan_args = [
- '--config', 'no', '--cache-dir', str(tmp_path), '--net',
- '-r', str(self.repos_dir / 'network'),
+ "--config",
+ "no",
+ "--cache-dir",
+ str(tmp_path),
+ "--net",
+ "-r",
+ str(self.repos_dir / "network"),
]
_net_results = [
(cls, result)
for _name, cls in sorted(objects.CHECKS.items())
if issubclass(cls, NetworkCheck)
- for result in sorted(cls.known_results, key=attrgetter('__name__'))
+ for result in sorted(cls.known_results, key=attrgetter("__name__"))
]
def _render_results(self, results, **kwargs):
@@ -50,34 +54,34 @@ class TestNetworkChecks:
output = f.read().decode()
return output
- @pytest.mark.parametrize('check, result', _net_results)
+ @pytest.mark.parametrize("check, result", _net_results)
def test_scan(self, check, result):
check_name = check.__name__
keyword = result.__name__
- result_dir = self.repos_dir / 'network' / check_name
- paths = tuple(result_dir.glob(keyword + '*'))
+ result_dir = self.repos_dir / "network" / check_name
+ paths = tuple(result_dir.glob(keyword + "*"))
if not paths:
- pytest.skip('data unavailable')
+ pytest.skip("data unavailable")
for path in paths:
ebuild_name = os.path.basename(path)
- data_dir = self.repos_data / 'network' / check_name / ebuild_name
+ data_dir = self.repos_data / "network" / check_name / ebuild_name
# load response data to fake
- module_path = path / 'responses.py'
- spec = importlib.util.spec_from_file_location('responses_mod', module_path)
+ module_path = path / "responses.py"
+ spec = importlib.util.spec_from_file_location("responses_mod", module_path)
responses_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(responses_mod)
results = []
- args = ['-c', check_name, '-k', keyword, f'{check_name}/{ebuild_name}']
- with patch('pkgcheck.addons.net.requests.Session.send') as send:
+ args = ["-c", check_name, "-k", keyword, f"{check_name}/{ebuild_name}"]
+ with patch("pkgcheck.addons.net.requests.Session.send") as send:
send.side_effect = responses_mod.responses
# load expected results if they exist
try:
- with (data_dir / 'expected.json').open() as f:
+ with (data_dir / "expected.json").open() as f:
expected_results = set(reporters.JsonStream.from_iter(f))
except FileNotFoundError:
# check stopped before making request or completed successfully
@@ -85,37 +89,42 @@ class TestNetworkChecks:
results = list(self.scan(self.scan_args + args))
rendered_results = self._render_results(results)
- assert rendered_results, 'failed rendering results'
+ assert rendered_results, "failed rendering results"
if set(results) != expected_results:
- error = ['unmatched results:']
+ error = ["unmatched results:"]
expected = self._render_results(expected_results)
- error.append(f'expected:\n{expected}')
- error.append(f'got:\n{rendered_results}')
- pytest.fail('\n'.join(error))
-
- @pytest.mark.parametrize('check, result', (
- (HomepageUrlCheck, DeadUrl),
- (FetchablesUrlCheck, DeadUrl),
- ))
+ error.append(f"expected:\n{expected}")
+ error.append(f"got:\n{rendered_results}")
+ pytest.fail("\n".join(error))
+
+ @pytest.mark.parametrize(
+ "check, result",
+ (
+ (HomepageUrlCheck, DeadUrl),
+ (FetchablesUrlCheck, DeadUrl),
+ ),
+ )
def test_scan_ftp(self, check, result):
check_name = check.__name__
keyword = result.__name__
- pkg = RawCPV(check_name, f'ftp-{keyword}', '0')
- if check_name == 'HomepageUrlCheck':
- deadurl = DeadUrl('HOMEPAGE', 'ftp://pkgcheck.net/pkgcheck/', 'dead ftp', pkg=pkg)
+ pkg = RawCPV(check_name, f"ftp-{keyword}", "0")
+ if check_name == "HomepageUrlCheck":
+ deadurl = DeadUrl("HOMEPAGE", "ftp://pkgcheck.net/pkgcheck/", "dead ftp", pkg=pkg)
else:
- deadurl = DeadUrl('SRC_URI', 'ftp://pkgcheck.net/pkgcheck/foo.tar.gz', 'dead ftp', pkg=pkg)
+ deadurl = DeadUrl(
+ "SRC_URI", "ftp://pkgcheck.net/pkgcheck/foo.tar.gz", "dead ftp", pkg=pkg
+ )
data = (
- (urllib.error.URLError('dead ftp'), deadurl),
- (socket.timeout('dead ftp'), deadurl),
+ (urllib.error.URLError("dead ftp"), deadurl),
+ (socket.timeout("dead ftp"), deadurl),
(None, None), # faking a clean connection
)
- args = ['-c', check_name, '-k', keyword, f'{check_name}/ftp-{keyword}']
+ args = ["-c", check_name, "-k", keyword, f"{check_name}/ftp-{keyword}"]
for side_effect, expected_result in data:
- with patch('pkgcheck.checks.network.urllib.request.urlopen') as urlopen:
+ with patch("pkgcheck.checks.network.urllib.request.urlopen") as urlopen:
if side_effect is not None:
urlopen.side_effect = side_effect
results = list(self.scan(self.scan_args + args))
@@ -123,4 +132,4 @@ class TestNetworkChecks:
assert not results
else:
assert results == [expected_result]
- assert self._render_results(results), 'failed rendering results'
+ assert self._render_results(results), "failed rendering results"
diff --git a/tests/checks/test_perl.py b/tests/checks/test_perl.py
index b9c25578..1b26e412 100644
--- a/tests/checks/test_perl.py
+++ b/tests/checks/test_perl.py
@@ -6,7 +6,7 @@ from snakeoil.cli import arghparse
from .. import misc
-REASON = ''
+REASON = ""
def perl_deps_missing():
@@ -28,49 +28,49 @@ class TestPerlCheck(misc.ReportTestCase):
def mk_check(self, verbosity=0):
return self.check_kls(arghparse.Namespace(verbosity=verbosity))
- def mk_pkg(self, PVR, dist_version='', eclasses=('perl-module',), **kwargs):
- lines = ['inherit perl-module\n']
+ def mk_pkg(self, PVR, dist_version="", eclasses=("perl-module",), **kwargs):
+ lines = ["inherit perl-module\n"]
if dist_version:
- lines.append(f'DIST_VERSION={dist_version}\n')
- kwargs.setdefault('EAPI', '7')
- kwargs.setdefault('_eclasses_', list(eclasses))
- return misc.FakePkg(f'app-foo/bar-{PVR}', lines=lines, data=kwargs)
+ lines.append(f"DIST_VERSION={dist_version}\n")
+ kwargs.setdefault("EAPI", "7")
+ kwargs.setdefault("_eclasses_", list(eclasses))
+ return misc.FakePkg(f"app-foo/bar-{PVR}", lines=lines, data=kwargs)
def test_matching(self):
"""Ebuilds with matching DIST_VERSION and package version."""
- for PVR in ('1.7.0-r0', '1.7.0', '1.7.0-r100'):
- self.assertNoReport(self.mk_check(), self.mk_pkg(PVR, '1.007'))
+ for PVR in ("1.7.0-r0", "1.7.0", "1.7.0-r100"):
+ self.assertNoReport(self.mk_check(), self.mk_pkg(PVR, "1.007"))
def test_nonmatching(self):
"""Ebuilds without matching DIST_VERSION and package version."""
- for PVR in ('1.7.0-r0', '1.7.0', '1.7.0-r100'):
- r = self.assertReport(self.mk_check(), self.mk_pkg(PVR, '1.07'))
+ for PVR in ("1.7.0-r0", "1.7.0", "1.7.0-r100"):
+ r = self.assertReport(self.mk_check(), self.mk_pkg(PVR, "1.07"))
assert isinstance(r, perl.MismatchedPerlVersion)
- assert r.dist_version == '1.07'
- assert r.normalized == '1.70.0'
- assert 'DIST_VERSION=1.07 normalizes to 1.70.0' in str(r)
- r = self.assertReport(self.mk_check(), self.mk_pkg(PVR, '1.7'))
+ assert r.dist_version == "1.07"
+ assert r.normalized == "1.70.0"
+ assert "DIST_VERSION=1.07 normalizes to 1.70.0" in str(r)
+ r = self.assertReport(self.mk_check(), self.mk_pkg(PVR, "1.7"))
assert isinstance(r, perl.MismatchedPerlVersion)
- assert r.dist_version == '1.7'
- assert r.normalized == '1.700.0'
- assert 'DIST_VERSION=1.7 normalizes to 1.700.0' in str(r)
+ assert r.dist_version == "1.7"
+ assert r.normalized == "1.700.0"
+ assert "DIST_VERSION=1.7 normalizes to 1.700.0" in str(r)
def test_no_dist_version(self):
"""Ebuilds without DIST_VERSION defined are skipped."""
- self.assertNoReport(self.mk_check(), self.mk_pkg('1.7.0'))
+ self.assertNoReport(self.mk_check(), self.mk_pkg("1.7.0"))
def test_no_perl(self):
"""Check initialization fails if perl isn't installed."""
- with patch('subprocess.Popen') as popen:
- popen.side_effect = FileNotFoundError('perl not available')
- with pytest.raises(SkipCheck, match='perl not installed'):
+ with patch("subprocess.Popen") as popen:
+ popen.side_effect = FileNotFoundError("perl not available")
+ with pytest.raises(SkipCheck, match="perl not installed"):
self.mk_check()
def test_no_perl_deps(self):
"""Check initialization fails if perl deps aren't installed."""
- with patch('pkgcheck.checks.perl.subprocess.Popen') as popen:
- popen.return_value.stdout.readline.return_value = 'perl error'
+ with patch("pkgcheck.checks.perl.subprocess.Popen") as popen:
+ popen.return_value.stdout.readline.return_value = "perl error"
popen.return_value.poll.return_value = 2
for verbosity in (0, 1):
- with pytest.raises(SkipCheck, match='failed to run perl script'):
+ with pytest.raises(SkipCheck, match="failed to run perl script"):
self.mk_check(verbosity=verbosity)
diff --git a/tests/checks/test_pkgdir.py b/tests/checks/test_pkgdir.py
index 1fc01b01..2a26e79c 100644
--- a/tests/checks/test_pkgdir.py
+++ b/tests/checks/test_pkgdir.py
@@ -21,33 +21,34 @@ class PkgDirCheckBase(misc.ReportTestCase):
@pytest.fixture(autouse=True)
def _create_repo(self, tmpdir):
- self.repo = FakeRepo(repo_id='repo', location=str(tmpdir))
+ self.repo = FakeRepo(repo_id="repo", location=str(tmpdir))
def mk_check(self, gentoo=False):
options = arghparse.Namespace(
- target_repo=self.repo, cache={'git': False}, gentoo_repo=gentoo)
+ target_repo=self.repo, cache={"git": False}, gentoo_repo=gentoo
+ )
kwargs = {}
if addons.git.GitAddon in self.check_kls.required_addons:
- kwargs['git_addon'] = addons.git.GitAddon(options)
+ kwargs["git_addon"] = addons.git.GitAddon(options)
return self.check_kls(options, **kwargs)
- def mk_pkg(self, files={}, category=None, package=None, version='0.7.1', revision=''):
+ def mk_pkg(self, files={}, category=None, package=None, version="0.7.1", revision=""):
# generate random cat/PN
category = misc.random_str() if category is None else category
package = misc.random_str() if package is None else package
pkg = f"{category}/{package}-{version}{revision}"
- self.filesdir = pjoin(self.repo.location, category, package, 'files')
+ self.filesdir = pjoin(self.repo.location, category, package, "files")
# create files dir with random empty subdir
os.makedirs(pjoin(self.filesdir, misc.random_str()), exist_ok=True)
# create dirs that should be ignored
- for d in getattr(self.check_kls, 'ignore_dirs', ()):
+ for d in getattr(self.check_kls, "ignore_dirs", ()):
os.makedirs(pjoin(self.filesdir, d), exist_ok=True)
# create specified files in FILESDIR
for fn, contents in files.items():
- with open(pjoin(self.filesdir, fn), 'w') as file:
+ with open(pjoin(self.filesdir, fn), "w") as file:
file.write(contents)
return misc.FakeFilesDirPkg(pkg, repo=self.repo)
@@ -64,24 +65,30 @@ class TestDuplicateFiles(PkgDirCheckBase):
"""Check DuplicateFiles results."""
def test_unique_files(self):
- self.assertNoReport(self.mk_check(), [self.mk_pkg({'test': 'abc', 'test2': 'bcd'})])
+ self.assertNoReport(self.mk_check(), [self.mk_pkg({"test": "abc", "test2": "bcd"})])
def test_single_duplicate(self):
- pkg = self.mk_pkg({'test': 'abc', 'test2': 'abc'})
+ pkg = self.mk_pkg({"test": "abc", "test2": "abc"})
r = self.assertReport(self.mk_check(), [pkg])
assert isinstance(r, pkgdir.DuplicateFiles)
- assert r.files == ('files/test', 'files/test2')
+ assert r.files == ("files/test", "files/test2")
assert "'files/test', 'files/test2'" in str(r)
def test_multiple_duplicates(self):
- r = self.assertReports(self.mk_check(), [self.mk_pkg(
- {'test': 'abc', 'test2': 'abc', 'test3': 'bcd', 'test4': 'bcd', 'test5': 'zzz'})])
+ r = self.assertReports(
+ self.mk_check(),
+ [
+ self.mk_pkg(
+ {"test": "abc", "test2": "abc", "test3": "bcd", "test4": "bcd", "test5": "zzz"}
+ )
+ ],
+ )
assert len(r) == 2
assert isinstance(r[0], pkgdir.DuplicateFiles)
assert isinstance(r[1], pkgdir.DuplicateFiles)
- assert (
- tuple(sorted(x.files for x in r)) ==
- (('files/test', 'files/test2'), ('files/test3', 'files/test4'))
+ assert tuple(sorted(x.files for x in r)) == (
+ ("files/test", "files/test2"),
+ ("files/test3", "files/test4"),
)
@@ -89,29 +96,29 @@ class TestEmptyFile(PkgDirCheckBase):
"""Check EmptyFile results."""
def test_nonempty_file(self):
- self.assertNoReport(self.mk_check(), [self.mk_pkg({'test': 'asdfgh'})])
+ self.assertNoReport(self.mk_check(), [self.mk_pkg({"test": "asdfgh"})])
def test_single_empty_file(self):
assert isinstance(
- self.assertReport(self.mk_check(), [self.mk_pkg({'test': ''})]),
- pkgdir.EmptyFile)
+ self.assertReport(self.mk_check(), [self.mk_pkg({"test": ""})]), pkgdir.EmptyFile
+ )
def test_multiple_empty_files(self):
- r = self.assertReports(self.mk_check(), [self.mk_pkg({'test': '', 'test2': ''})])
+ r = self.assertReports(self.mk_check(), [self.mk_pkg({"test": "", "test2": ""})])
assert len(r) == 2
assert isinstance(r[0], pkgdir.EmptyFile)
assert isinstance(r[1], pkgdir.EmptyFile)
- assert sorted(x.filename for x in r) == ['files/test', 'files/test2']
+ assert sorted(x.filename for x in r) == ["files/test", "files/test2"]
def test_mixture_of_files(self):
- r = self.assertReport(self.mk_check(), [self.mk_pkg({'test': 'asdfgh', 'test2': ''})])
+ r = self.assertReport(self.mk_check(), [self.mk_pkg({"test": "asdfgh", "test2": ""})])
assert isinstance(r, pkgdir.EmptyFile)
- assert r.filename == 'files/test2'
- assert 'files/test2' in str(r)
- r = self.assertReport(self.mk_check(), [self.mk_pkg({'test': '', 'test2': 'asdfgh'})])
+ assert r.filename == "files/test2"
+ assert "files/test2" in str(r)
+ r = self.assertReport(self.mk_check(), [self.mk_pkg({"test": "", "test2": "asdfgh"})])
assert isinstance(r, pkgdir.EmptyFile)
- assert r.filename == 'files/test'
- assert 'files/test' in str(r)
+ assert r.filename == "files/test"
+ assert "files/test" in str(r)
class TestMismatchedPN(PkgDirCheckBase):
@@ -119,29 +126,29 @@ class TestMismatchedPN(PkgDirCheckBase):
def test_multiple_regular_ebuilds(self):
pkg = self.mk_pkg()
- touch(pjoin(os.path.dirname(pkg.path), f'{pkg.package}-0.ebuild'))
- touch(pjoin(os.path.dirname(pkg.path), f'{pkg.package}-1.ebuild'))
- touch(pjoin(os.path.dirname(pkg.path), f'{pkg.package}-2.ebuild'))
+ touch(pjoin(os.path.dirname(pkg.path), f"{pkg.package}-0.ebuild"))
+ touch(pjoin(os.path.dirname(pkg.path), f"{pkg.package}-1.ebuild"))
+ touch(pjoin(os.path.dirname(pkg.path), f"{pkg.package}-2.ebuild"))
self.assertNoReport(self.mk_check(), [pkg])
def test_single_mismatched_ebuild(self):
pkg = self.mk_pkg()
- touch(pjoin(os.path.dirname(pkg.path), 'mismatched-0.ebuild'))
+ touch(pjoin(os.path.dirname(pkg.path), "mismatched-0.ebuild"))
r = self.assertReport(self.mk_check(), [pkg])
assert isinstance(r, pkgdir.MismatchedPN)
- assert r.ebuilds == ('mismatched-0',)
- assert 'mismatched-0' in str(r)
+ assert r.ebuilds == ("mismatched-0",)
+ assert "mismatched-0" in str(r)
def test_multiple_mismatched_ebuilds(self):
pkg = self.mk_pkg()
- touch(pjoin(os.path.dirname(pkg.path), f'{pkg.package}-0.ebuild'))
- touch(pjoin(os.path.dirname(pkg.path), f'{pkg.package}-1.ebuild'))
- touch(pjoin(os.path.dirname(pkg.path), 'mismatched-0.ebuild'))
- touch(pjoin(os.path.dirname(pkg.path), 'abc-1.ebuild'))
+ touch(pjoin(os.path.dirname(pkg.path), f"{pkg.package}-0.ebuild"))
+ touch(pjoin(os.path.dirname(pkg.path), f"{pkg.package}-1.ebuild"))
+ touch(pjoin(os.path.dirname(pkg.path), "mismatched-0.ebuild"))
+ touch(pjoin(os.path.dirname(pkg.path), "abc-1.ebuild"))
r = self.assertReport(self.mk_check(), [pkg])
assert isinstance(r, pkgdir.MismatchedPN)
- assert r.ebuilds == ('abc-1', 'mismatched-0')
- assert 'abc-1, mismatched-0' in str(r)
+ assert r.ebuilds == ("abc-1", "mismatched-0")
+ assert "abc-1, mismatched-0" in str(r)
class TestInvalidPN(PkgDirCheckBase):
@@ -149,27 +156,27 @@ class TestInvalidPN(PkgDirCheckBase):
def test_regular_ebuild(self):
pkg = self.mk_pkg()
- touch(pjoin(os.path.dirname(pkg.path), f'{pkg.package}-0.ebuild'))
+ touch(pjoin(os.path.dirname(pkg.path), f"{pkg.package}-0.ebuild"))
self.assertNoReport(self.mk_check(), [pkg])
def test_single_invalid_ebuild(self):
- pkg = self.mk_pkg(category='sys-apps', package='invalid')
- touch(pjoin(os.path.dirname(pkg.path), 'invalid-0-foo.ebuild'))
+ pkg = self.mk_pkg(category="sys-apps", package="invalid")
+ touch(pjoin(os.path.dirname(pkg.path), "invalid-0-foo.ebuild"))
r = self.assertReport(self.mk_check(), [pkg])
assert isinstance(r, pkgdir.InvalidPN)
- assert r.ebuilds == ('invalid-0-foo',)
- assert 'invalid-0-foo' in str(r)
+ assert r.ebuilds == ("invalid-0-foo",)
+ assert "invalid-0-foo" in str(r)
def test_multiple_invalid_ebuilds(self):
- pkg = self.mk_pkg(category='sys-apps', package='bar')
- touch(pjoin(os.path.dirname(pkg.path), 'bar-0.ebuild'))
- touch(pjoin(os.path.dirname(pkg.path), 'bar-1.ebuild'))
- touch(pjoin(os.path.dirname(pkg.path), 'bar-0-foo1.ebuild'))
- touch(pjoin(os.path.dirname(pkg.path), 'bar-1-foo2.ebuild'))
+ pkg = self.mk_pkg(category="sys-apps", package="bar")
+ touch(pjoin(os.path.dirname(pkg.path), "bar-0.ebuild"))
+ touch(pjoin(os.path.dirname(pkg.path), "bar-1.ebuild"))
+ touch(pjoin(os.path.dirname(pkg.path), "bar-0-foo1.ebuild"))
+ touch(pjoin(os.path.dirname(pkg.path), "bar-1-foo2.ebuild"))
r = self.assertReport(self.mk_check(), [pkg])
assert isinstance(r, pkgdir.InvalidPN)
- assert r.ebuilds == ('bar-0-foo1', 'bar-1-foo2')
- assert 'bar-0-foo1, bar-1-foo2' in str(r)
+ assert r.ebuilds == ("bar-0-foo1", "bar-1-foo2")
+ assert "bar-0-foo1, bar-1-foo2" in str(r)
class TestInvalidUTF8(PkgDirCheckBase):
@@ -177,26 +184,26 @@ class TestInvalidUTF8(PkgDirCheckBase):
def test_ascii_ebuild(self):
pkg = self.mk_pkg()
- ebuild_path = pjoin(os.path.dirname(pkg.path), f'{pkg.package}-0.ebuild')
- with open(ebuild_path, 'w', encoding='ascii') as f:
+ ebuild_path = pjoin(os.path.dirname(pkg.path), f"{pkg.package}-0.ebuild")
+ with open(ebuild_path, "w", encoding="ascii") as f:
f.write('EAPI=7\nDESCRIPTION="foobar"\n')
self.assertNoReport(self.mk_check(), [pkg])
def test_utf8_ebuild(self):
pkg = self.mk_pkg()
- ebuild_path = pjoin(os.path.dirname(pkg.path), f'{pkg.package}-0.ebuild')
- with open(ebuild_path, 'w') as f:
+ ebuild_path = pjoin(os.path.dirname(pkg.path), f"{pkg.package}-0.ebuild")
+ with open(ebuild_path, "w") as f:
f.write('EAPI=6\nDESCRIPTION="fóóbár"\n')
self.assertNoReport(self.mk_check(), [pkg])
def test_latin1_ebuild(self):
pkg = self.mk_pkg()
- ebuild_path = pjoin(os.path.dirname(pkg.path), f'{pkg.package}-0.ebuild')
- with open(ebuild_path, 'w', encoding='latin-1') as f:
+ ebuild_path = pjoin(os.path.dirname(pkg.path), f"{pkg.package}-0.ebuild")
+ with open(ebuild_path, "w", encoding="latin-1") as f:
f.write('EAPI=5\nDESCRIPTION="fôòbår"\n')
r = self.assertReport(self.mk_check(), [pkg])
assert isinstance(r, pkgdir.InvalidUTF8)
- assert r.filename == f'{pkg.package}-0.ebuild'
+ assert r.filename == f"{pkg.package}-0.ebuild"
assert r.filename in str(r)
@@ -207,44 +214,48 @@ class TestEqualVersions(PkgDirCheckBase):
def test_it(self):
# pkg with no revision
- pkg_a = self.mk_pkg(version='0')
+ pkg_a = self.mk_pkg(version="0")
self.assertNoReport(self.mk_check(), [pkg_a])
# single, matching revision
pkg_b = self.mk_pkg(
- category=pkg_a.category, package=pkg_a.package, version='0', revision='-r0')
+ category=pkg_a.category, package=pkg_a.package, version="0", revision="-r0"
+ )
r = self.assertReport(self.mk_check(), [pkg_a, pkg_b])
assert isinstance(r, pkgdir.EqualVersions)
- assert r.versions == ('0', '0-r0')
- assert '[ 0, 0-r0 ]' in str(r)
+ assert r.versions == ("0", "0-r0")
+ assert "[ 0, 0-r0 ]" in str(r)
# multiple, matching revisions
pkg_c = self.mk_pkg(
- category=pkg_a.category, package=pkg_a.package, version='0', revision='-r000')
+ category=pkg_a.category, package=pkg_a.package, version="0", revision="-r000"
+ )
r = self.assertReport(self.mk_check(), [pkg_a, pkg_b, pkg_c])
assert isinstance(r, pkgdir.EqualVersions)
- assert r.versions == ('0', '0-r0', '0-r000')
- assert '[ 0, 0-r0, 0-r000 ]' in str(r)
+ assert r.versions == ("0", "0-r0", "0-r000")
+ assert "[ 0, 0-r0, 0-r000 ]" in str(r)
# unsorted, matching revisions
- pkg_new_version = self.mk_pkg(
- category=pkg_a.category, package=pkg_a.package, version='1')
+ pkg_new_version = self.mk_pkg(category=pkg_a.category, package=pkg_a.package, version="1")
r = self.assertReport(self.mk_check(), [pkg_b, pkg_new_version, pkg_c, pkg_a])
assert isinstance(r, pkgdir.EqualVersions)
- assert r.versions == ('0', '0-r0', '0-r000')
- assert '[ 0, 0-r0, 0-r000 ]' in str(r)
+ assert r.versions == ("0", "0-r0", "0-r000")
+ assert "[ 0, 0-r0, 0-r000 ]" in str(r)
# multiple, matching revisions with 0 prefixes
pkg_d = self.mk_pkg(
- category=pkg_a.category, package=pkg_a.package, version='0', revision='-r1')
+ category=pkg_a.category, package=pkg_a.package, version="0", revision="-r1"
+ )
pkg_e = self.mk_pkg(
- category=pkg_a.category, package=pkg_a.package, version='0', revision='-r01')
+ category=pkg_a.category, package=pkg_a.package, version="0", revision="-r01"
+ )
pkg_f = self.mk_pkg(
- category=pkg_a.category, package=pkg_a.package, version='0', revision='-r001')
+ category=pkg_a.category, package=pkg_a.package, version="0", revision="-r001"
+ )
r = self.assertReport(self.mk_check(), [pkg_d, pkg_e, pkg_f])
assert isinstance(r, pkgdir.EqualVersions)
- assert r.versions == ('0-r001', '0-r01', '0-r1')
- assert '[ 0-r001, 0-r01, 0-r1 ]' in str(r)
+ assert r.versions == ("0-r001", "0-r01", "0-r1")
+ assert "[ 0-r001, 0-r01, 0-r1 ]" in str(r)
class TestSizeViolation(PkgDirCheckBase):
@@ -252,50 +263,51 @@ class TestSizeViolation(PkgDirCheckBase):
def test_files_under_size_limit(self):
pkg = self.mk_pkg()
- for name, size in (('small', 1024*10),
- ('limit', 1024*20-1)):
- with open(pjoin(self.filesdir, name), 'w') as f:
+ for name, size in (("small", 1024 * 10), ("limit", 1024 * 20 - 1)):
+ with open(pjoin(self.filesdir, name), "w") as f:
f.seek(size)
- f.write('\0')
+ f.write("\0")
self.assertNoReport(self.mk_check(), [pkg])
def test_single_file_over_limit(self):
pkg = self.mk_pkg()
- with open(pjoin(self.filesdir, 'over'), 'w') as f:
- f.seek(1024*20)
- f.write('\0')
+ with open(pjoin(self.filesdir, "over"), "w") as f:
+ f.seek(1024 * 20)
+ f.write("\0")
r = self.assertReport(self.mk_check(), [pkg])
assert isinstance(r, pkgdir.SizeViolation)
- assert r.filename == 'files/over'
- assert r.size == 1024*20+1
- assert 'files/over' in str(r)
+ assert r.filename == "files/over"
+ assert r.size == 1024 * 20 + 1
+ assert "files/over" in str(r)
def test_multiple_files_over_limit(self):
pkg = self.mk_pkg()
- for name, size in (('small', 1024*10),
- ('limit', 1024*20-1),
- ('over', 1024*20),
- ('massive', 1024*100)):
- with open(pjoin(self.filesdir, name), 'w') as f:
+ for name, size in (
+ ("small", 1024 * 10),
+ ("limit", 1024 * 20 - 1),
+ ("over", 1024 * 20),
+ ("massive", 1024 * 100),
+ ):
+ with open(pjoin(self.filesdir, name), "w") as f:
f.seek(size)
- f.write('\0')
+ f.write("\0")
r = self.assertReports(self.mk_check(), [pkg])
assert len(r) == 3
assert isinstance(r[0], pkgdir.SizeViolation)
assert isinstance(r[1], pkgdir.SizeViolation)
assert isinstance(r[2], pkgdir.TotalSizeViolation)
- assert (
- tuple(sorted((x.filename, x.size) for x in r[:2])) ==
- (('files/massive', 1024*100+1), ('files/over', 1024*20+1))
+ assert tuple(sorted((x.filename, x.size) for x in r[:2])) == (
+ ("files/massive", 1024 * 100 + 1),
+ ("files/over", 1024 * 20 + 1),
)
- assert r[2].size == 1024*(10+20+20+100)+4-1
+ assert r[2].size == 1024 * (10 + 20 + 20 + 100) + 4 - 1
class TestExecutableFile(PkgDirCheckBase):
"""Check ExecutableFile results."""
def test_non_empty_filesdir(self):
- self.assertNoReport(self.mk_check(), [self.mk_pkg({'test': 'asdfgh'})])
+ self.assertNoReport(self.mk_check(), [self.mk_pkg({"test": "asdfgh"})])
def test_executable_ebuild(self):
pkg = self.mk_pkg()
@@ -307,54 +319,53 @@ class TestExecutableFile(PkgDirCheckBase):
def test_executable_manifest_and_metadata(self):
pkg = self.mk_pkg()
- touch(pjoin(os.path.dirname(pkg.path), 'Manifest'), mode=0o755)
- touch(pjoin(os.path.dirname(pkg.path), 'metadata.xml'), mode=0o744)
+ touch(pjoin(os.path.dirname(pkg.path), "Manifest"), mode=0o755)
+ touch(pjoin(os.path.dirname(pkg.path), "metadata.xml"), mode=0o744)
r = self.assertReports(self.mk_check(), [pkg])
assert len(r) == 2
assert isinstance(r[0], pkgdir.ExecutableFile)
assert isinstance(r[1], pkgdir.ExecutableFile)
- assert (
- tuple(sorted(x.filename for x in r)) ==
- ('Manifest', 'metadata.xml')
- )
+ assert tuple(sorted(x.filename for x in r)) == ("Manifest", "metadata.xml")
def test_executable_filesdir_file(self):
- pkg = self.mk_pkg({'foo.init': 'blah'})
+ pkg = self.mk_pkg({"foo.init": "blah"})
touch(pkg.path)
- touch(pjoin(os.path.dirname(pkg.path), 'Manifest'))
- touch(pjoin(os.path.dirname(pkg.path), 'metadata.xml'))
- os.chmod(pjoin(os.path.dirname(pkg.path), 'files', 'foo.init'), 0o645)
+ touch(pjoin(os.path.dirname(pkg.path), "Manifest"))
+ touch(pjoin(os.path.dirname(pkg.path), "metadata.xml"))
+ os.chmod(pjoin(os.path.dirname(pkg.path), "files", "foo.init"), 0o645)
r = self.assertReport(self.mk_check(), [pkg])
assert isinstance(r, pkgdir.ExecutableFile)
- assert r.filename == 'files/foo.init'
- assert 'files/foo.init' in str(r)
+ assert r.filename == "files/foo.init"
+ assert "files/foo.init" in str(r)
class TestBannedCharacter(PkgDirCheckBase):
"""Check BannedCharacter results."""
def test_regular_files(self):
- pkg = self.mk_pkg({'foo.init': 'blah'})
- touch(pjoin(os.path.dirname(pkg.path), 'Manifest'))
- touch(pjoin(os.path.dirname(pkg.path), 'metadata.xml'))
+ pkg = self.mk_pkg({"foo.init": "blah"})
+ touch(pjoin(os.path.dirname(pkg.path), "Manifest"))
+ touch(pjoin(os.path.dirname(pkg.path), "metadata.xml"))
self.assertNoReport(self.mk_check(), [pkg])
def test_filenames_outside_allowed_charsets(self):
- pkg = self.mk_pkg({
- 'foo.init': 'bar',
- 'foo.init~': 'foo',
- })
+ pkg = self.mk_pkg(
+ {
+ "foo.init": "bar",
+ "foo.init~": "foo",
+ }
+ )
# vim backup files are flagged by default
r = self.assertReport(self.mk_check(), [pkg])
assert isinstance(r, pkgdir.BannedCharacter)
- assert 'files/foo.init~' in str(r)
+ assert "files/foo.init~" in str(r)
# but results are suppressed if a matching git ignore entry exists
- for ignore_file in ('.gitignore', '.git/info/exclude'):
+ for ignore_file in (".gitignore", ".git/info/exclude"):
path = pjoin(self.repo.location, ignore_file)
ensure_dirs(os.path.dirname(path))
- with open(path, 'w') as f:
- f.write('*~')
+ with open(path, "w") as f:
+ f.write("*~")
self.assertNoReport(self.mk_check(), [pkg])
os.unlink(path)
@@ -363,40 +374,40 @@ class TestUnknownPkgDirEntry(PkgDirCheckBase):
"""Check UnknownPkgDirEntry results."""
def test_regular_files(self):
- pkg = self.mk_pkg({'foo.init': 'blah'})
- touch(pjoin(os.path.dirname(pkg.path), 'Manifest'))
- touch(pjoin(os.path.dirname(pkg.path), 'metadata.xml'))
+ pkg = self.mk_pkg({"foo.init": "blah"})
+ touch(pjoin(os.path.dirname(pkg.path), "Manifest"))
+ touch(pjoin(os.path.dirname(pkg.path), "metadata.xml"))
self.assertNoReport(self.mk_check(), [pkg])
def test_unknown_non_gentoo_repo(self):
- pkg = self.mk_pkg({'foo.init': 'blah'})
- touch(pjoin(os.path.dirname(pkg.path), 'Manifest'))
- touch(pjoin(os.path.dirname(pkg.path), 'metadata.xml'))
- touch(pjoin(os.path.dirname(pkg.path), 'foo-2'))
+ pkg = self.mk_pkg({"foo.init": "blah"})
+ touch(pjoin(os.path.dirname(pkg.path), "Manifest"))
+ touch(pjoin(os.path.dirname(pkg.path), "metadata.xml"))
+ touch(pjoin(os.path.dirname(pkg.path), "foo-2"))
self.assertNoReport(self.mk_check(), [pkg])
def test_unknown_gentoo_repo(self):
- pkg = self.mk_pkg({'foo.init': 'blah'})
- touch(pjoin(os.path.dirname(pkg.path), 'Manifest'))
- touch(pjoin(os.path.dirname(pkg.path), 'metadata.xml'))
- touch(pjoin(os.path.dirname(pkg.path), 'foo-2'))
+ pkg = self.mk_pkg({"foo.init": "blah"})
+ touch(pjoin(os.path.dirname(pkg.path), "Manifest"))
+ touch(pjoin(os.path.dirname(pkg.path), "metadata.xml"))
+ touch(pjoin(os.path.dirname(pkg.path), "foo-2"))
r = self.assertReport(self.mk_check(gentoo=True), [pkg])
assert isinstance(r, pkgdir.UnknownPkgDirEntry)
- assert 'foo-2' in str(r)
+ assert "foo-2" in str(r)
def test_unknown_gitignore(self):
- pkg = self.mk_pkg(files={'foo.init': 'blah'}, category='dev-util', package='foo')
- touch(pjoin(os.path.dirname(pkg.path), 'Manifest'))
- touch(pjoin(os.path.dirname(pkg.path), 'metadata.xml'))
- touch(pjoin(os.path.dirname(pkg.path), 'foo-0.ebuild'))
- touch(pjoin(os.path.dirname(pkg.path), 'foo-0.ebuild.swp'))
+ pkg = self.mk_pkg(files={"foo.init": "blah"}, category="dev-util", package="foo")
+ touch(pjoin(os.path.dirname(pkg.path), "Manifest"))
+ touch(pjoin(os.path.dirname(pkg.path), "metadata.xml"))
+ touch(pjoin(os.path.dirname(pkg.path), "foo-0.ebuild"))
+ touch(pjoin(os.path.dirname(pkg.path), "foo-0.ebuild.swp"))
r = self.assertReport(self.mk_check(gentoo=True), [pkg])
assert isinstance(r, pkgdir.UnknownPkgDirEntry)
- assert 'foo-0.ebuild.swp' in str(r)
+ assert "foo-0.ebuild.swp" in str(r)
# results are suppressed if a matching .gitignore entry exists
- with open(pjoin(self.repo.location, '.gitignore'), 'w') as f:
- f.write('*.swp')
+ with open(pjoin(self.repo.location, ".gitignore"), "w") as f:
+ f.write("*.swp")
self.assertNoReport(self.mk_check(gentoo=True), [pkg])
@@ -411,17 +422,17 @@ class TestLiveOnlyCheck(misc.ReportTestCase):
# initialize parent repo
self.parent_git_repo = make_git_repo()
- self.parent_repo = make_repo(self.parent_git_repo.path, repo_id='gentoo')
- self.parent_git_repo.add_all('initial commit')
+ self.parent_repo = make_repo(self.parent_git_repo.path, repo_id="gentoo")
+ self.parent_git_repo.add_all("initial commit")
# create a stub pkg and commit it
- self.parent_repo.create_ebuild('cat/pkg-0', properties='live')
- self.parent_git_repo.add_all('cat/pkg-0')
+ self.parent_repo.create_ebuild("cat/pkg-0", properties="live")
+ self.parent_git_repo.add_all("cat/pkg-0")
# initialize child repo
self.child_git_repo = make_git_repo()
- self.child_git_repo.run(['git', 'remote', 'add', 'origin', self.parent_git_repo.path])
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_git_repo.run(['git', 'remote', 'set-head', 'origin', 'main'])
+ self.child_git_repo.run(["git", "remote", "add", "origin", self.parent_git_repo.path])
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_git_repo.run(["git", "remote", "set-head", "origin", "main"])
self.child_repo = make_repo(self.child_git_repo.path)
def init_check(self, options=None, future=0):
@@ -434,45 +445,49 @@ class TestLiveOnlyCheck(misc.ReportTestCase):
def _options(self, **kwargs):
args = [
- 'scan', '-q', '--cache-dir', self.cache_dir,
- '--repo', self.child_repo.location,
+ "scan",
+ "-q",
+ "--cache-dir",
+ self.cache_dir,
+ "--repo",
+ self.child_repo.location,
]
options, _ = self._tool.parse_args(args)
return options
def test_no_git_support(self):
options = self._options()
- options.cache['git'] = False
- with pytest.raises(SkipCheck, match='git cache support required'):
+ options.cache["git"] = False
+ with pytest.raises(SkipCheck, match="git cache support required"):
self.init_check(options)
def test_keywords_exist(self):
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['~amd64'])
- self.parent_git_repo.add_all('cat/pkg-1')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["~amd64"])
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
self.init_check()
self.assertNoReport(self.check, self.source)
def test_all_live_pkgs(self):
- self.parent_repo.create_ebuild('cat/pkg-1', properties='live')
- self.parent_git_repo.add_all('cat/pkg-1')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
+ self.parent_repo.create_ebuild("cat/pkg-1", properties="live")
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
self.init_check()
# result will trigger for any package age
- expected = pkgdir.LiveOnlyPackage(0, pkg=UnversionedCPV('cat/pkg'))
+ expected = pkgdir.LiveOnlyPackage(0, pkg=UnversionedCPV("cat/pkg"))
r = self.assertReport(self.check, self.source)
assert r == expected
# packages are now a year old
self.init_check(future=365)
- expected = pkgdir.LiveOnlyPackage(365, pkg=UnversionedCPV('cat/pkg'))
+ expected = pkgdir.LiveOnlyPackage(365, pkg=UnversionedCPV("cat/pkg"))
r = self.assertReport(self.check, self.source)
assert r == expected
def test_uncommitted_local_ebuild(self):
- self.parent_repo.create_ebuild('cat/pkg-1', properties='live')
- self.parent_git_repo.add_all('cat/pkg-1')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_repo.create_ebuild('cat/pkg-2', properties='live')
+ self.parent_repo.create_ebuild("cat/pkg-1", properties="live")
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_repo.create_ebuild("cat/pkg-2", properties="live")
self.init_check(future=180)
self.assertNoReport(self.check, self.source)
diff --git a/tests/checks/test_python.py b/tests/checks/test_python.py
index 843975b5..eb4c44fb 100644
--- a/tests/checks/test_python.py
+++ b/tests/checks/test_python.py
@@ -9,180 +9,201 @@ class TestPythonCheck(misc.ReportTestCase):
check_kls = python.PythonCheck
def mk_pkg(self, cpv="app-foo/bar-1", **kwargs):
- kwargs.setdefault('EAPI', '7')
+ kwargs.setdefault("EAPI", "7")
return misc.FakePkg(cpv, data=kwargs)
def test_multiple_eclasses(self):
r = self.assertReport(
self.check,
- self.mk_pkg(_eclasses_=['python-any-r1', 'python-single-r1'],
- DEPEND='dev-lang/python'))
+ self.mk_pkg(_eclasses_=["python-any-r1", "python-single-r1"], DEPEND="dev-lang/python"),
+ )
assert isinstance(r, python.PythonEclassError)
def test_missing_eclass_depend(self):
self.assertNoReport(
- self.check,
- self.mk_pkg(_eclasses_=['python-any-r1'], DEPEND='dev-lang/python'))
- self.assertNoReport(self.check, self.mk_pkg(DEPEND='dev-foo/frobnicate'))
+ self.check, self.mk_pkg(_eclasses_=["python-any-r1"], DEPEND="dev-lang/python")
+ )
+ self.assertNoReport(self.check, self.mk_pkg(DEPEND="dev-foo/frobnicate"))
- r = self.assertReport(self.check, self.mk_pkg(DEPEND='dev-lang/python'))
+ r = self.assertReport(self.check, self.mk_pkg(DEPEND="dev-lang/python"))
assert isinstance(r, python.MissingPythonEclass)
assert 'missing python-any-r1 eclass usage for DEPEND="dev-lang/python"' in str(r)
- self.assertNoReport(self.check, self.mk_pkg(DEPEND='dev-lang/python:2.7'))
+ self.assertNoReport(self.check, self.mk_pkg(DEPEND="dev-lang/python:2.7"))
assert isinstance(
- self.assertReport(self.check, self.mk_pkg(DEPEND='dev-lang/python:*')),
- python.MissingPythonEclass)
+ self.assertReport(self.check, self.mk_pkg(DEPEND="dev-lang/python:*")),
+ python.MissingPythonEclass,
+ )
assert isinstance(
- self.assertReport(self.check, self.mk_pkg(DEPEND='=dev-lang/python-2*')),
- python.MissingPythonEclass)
+ self.assertReport(self.check, self.mk_pkg(DEPEND="=dev-lang/python-2*")),
+ python.MissingPythonEclass,
+ )
assert isinstance(
self.assertReport(
- self.check,
- self.mk_pkg(DEPEND='|| ( dev-lang/python:2.7 dev-lang/python:3.6 )')),
- python.MissingPythonEclass)
+ self.check, self.mk_pkg(DEPEND="|| ( dev-lang/python:2.7 dev-lang/python:3.6 )")
+ ),
+ python.MissingPythonEclass,
+ )
def test_missing_eclass_bdepend(self):
self.assertNoReport(
- self.check,
- self.mk_pkg(_eclasses_=['python-any-r1'], BDEPEND='dev-lang/python'))
- self.assertNoReport(self.check, self.mk_pkg(BDEPEND='dev-foo/frobnicate'))
+ self.check, self.mk_pkg(_eclasses_=["python-any-r1"], BDEPEND="dev-lang/python")
+ )
+ self.assertNoReport(self.check, self.mk_pkg(BDEPEND="dev-foo/frobnicate"))
assert isinstance(
- self.assertReport(self.check, self.mk_pkg(BDEPEND='dev-lang/python')),
- python.MissingPythonEclass)
- self.assertNoReport(self.check, self.mk_pkg(BDEPEND='dev-lang/python:2.7'))
+ self.assertReport(self.check, self.mk_pkg(BDEPEND="dev-lang/python")),
+ python.MissingPythonEclass,
+ )
+ self.assertNoReport(self.check, self.mk_pkg(BDEPEND="dev-lang/python:2.7"))
assert isinstance(
- self.assertReport(self.check, self.mk_pkg(BDEPEND='dev-lang/python:*')),
- python.MissingPythonEclass)
+ self.assertReport(self.check, self.mk_pkg(BDEPEND="dev-lang/python:*")),
+ python.MissingPythonEclass,
+ )
assert isinstance(
- self.assertReport(self.check, self.mk_pkg(BDEPEND='=dev-lang/python-2*')),
- python.MissingPythonEclass)
+ self.assertReport(self.check, self.mk_pkg(BDEPEND="=dev-lang/python-2*")),
+ python.MissingPythonEclass,
+ )
assert isinstance(
self.assertReport(
- self.check,
- self.mk_pkg(BDEPEND='|| ( dev-lang/python:2.7 dev-lang/python:3.6 )')),
- python.MissingPythonEclass)
+ self.check, self.mk_pkg(BDEPEND="|| ( dev-lang/python:2.7 dev-lang/python:3.6 )")
+ ),
+ python.MissingPythonEclass,
+ )
def test_missing_eclass_rdepend(self):
self.assertNoReport(
- self.check,
- self.mk_pkg(_eclasses_=['python-r1'], RDEPEND='dev-lang/python:3.7'))
+ self.check, self.mk_pkg(_eclasses_=["python-r1"], RDEPEND="dev-lang/python:3.7")
+ )
self.assertNoReport(
- self.check,
- self.mk_pkg(_eclasses_=['python-single-r1'], RDEPEND='dev-lang/python:3.7'))
- self.assertNoReport(self.check, self.mk_pkg(RDEPEND='dev-foo/frobnicate'))
+ self.check, self.mk_pkg(_eclasses_=["python-single-r1"], RDEPEND="dev-lang/python:3.7")
+ )
+ self.assertNoReport(self.check, self.mk_pkg(RDEPEND="dev-foo/frobnicate"))
- r = self.assertReport(self.check, self.mk_pkg(RDEPEND='dev-lang/python'))
+ r = self.assertReport(self.check, self.mk_pkg(RDEPEND="dev-lang/python"))
assert isinstance(r, python.MissingPythonEclass)
- assert 'missing python-r1 or python-single-r1 eclass' in str(r)
+ assert "missing python-r1 or python-single-r1 eclass" in str(r)
- self.assertNoReport(self.check, self.mk_pkg(RDEPEND='dev-lang/python:2.7'))
+ self.assertNoReport(self.check, self.mk_pkg(RDEPEND="dev-lang/python:2.7"))
assert isinstance(
- self.assertReport(self.check, self.mk_pkg(RDEPEND='dev-lang/python:=')),
- python.MissingPythonEclass)
+ self.assertReport(self.check, self.mk_pkg(RDEPEND="dev-lang/python:=")),
+ python.MissingPythonEclass,
+ )
assert isinstance(
- self.assertReport(self.check, self.mk_pkg(RDEPEND='=dev-lang/python-2*')),
- python.MissingPythonEclass)
+ self.assertReport(self.check, self.mk_pkg(RDEPEND="=dev-lang/python-2*")),
+ python.MissingPythonEclass,
+ )
assert isinstance(
self.assertReport(
- self.check,
- self.mk_pkg(RDEPEND='|| ( dev-lang/python:2.7 dev-lang/python:3.6 )')),
- python.MissingPythonEclass)
+ self.check, self.mk_pkg(RDEPEND="|| ( dev-lang/python:2.7 dev-lang/python:3.6 )")
+ ),
+ python.MissingPythonEclass,
+ )
def test_missing_eclass_pdepend(self):
self.assertNoReport(
- self.check,
- self.mk_pkg(_eclasses_=['python-r1'], PDEPEND='dev-lang/python:3.7'))
+ self.check, self.mk_pkg(_eclasses_=["python-r1"], PDEPEND="dev-lang/python:3.7")
+ )
self.assertNoReport(
- self.check,
- self.mk_pkg(_eclasses_=['python-single-r1'], PDEPEND='dev-lang/python:3.7'))
- self.assertNoReport(self.check, self.mk_pkg(PDEPEND='dev-foo/frobnicate'))
+ self.check, self.mk_pkg(_eclasses_=["python-single-r1"], PDEPEND="dev-lang/python:3.7")
+ )
+ self.assertNoReport(self.check, self.mk_pkg(PDEPEND="dev-foo/frobnicate"))
assert isinstance(
- self.assertReport(self.check, self.mk_pkg(PDEPEND='dev-lang/python')),
- python.MissingPythonEclass)
- self.assertNoReport(self.check, self.mk_pkg(PDEPEND='dev-lang/python:2.7'))
+ self.assertReport(self.check, self.mk_pkg(PDEPEND="dev-lang/python")),
+ python.MissingPythonEclass,
+ )
+ self.assertNoReport(self.check, self.mk_pkg(PDEPEND="dev-lang/python:2.7"))
assert isinstance(
- self.assertReport(self.check, self.mk_pkg(PDEPEND='dev-lang/python:=')),
- python.MissingPythonEclass)
+ self.assertReport(self.check, self.mk_pkg(PDEPEND="dev-lang/python:=")),
+ python.MissingPythonEclass,
+ )
assert isinstance(
- self.assertReport(self.check, self.mk_pkg(PDEPEND='=dev-lang/python-2*')),
- python.MissingPythonEclass)
+ self.assertReport(self.check, self.mk_pkg(PDEPEND="=dev-lang/python-2*")),
+ python.MissingPythonEclass,
+ )
assert isinstance(
self.assertReport(
- self.check,
- self.mk_pkg(PDEPEND='|| ( dev-lang/python:2.7 dev-lang/python:3.6 )')),
- python.MissingPythonEclass)
+ self.check, self.mk_pkg(PDEPEND="|| ( dev-lang/python:2.7 dev-lang/python:3.6 )")
+ ),
+ python.MissingPythonEclass,
+ )
def test_valid_packages(self):
self.assertNoReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6',
- RDEPEND='python_targets_python3_5? ( '
- ' dev-lang/python:3.5 ) '
- 'python_targets_python3_6? ( '
- ' dev-lang/python:3.6 )',
- REQUIRED_USE='|| ( python_targets_python3_5 '
- ' python_targets_python3_6 )'))
+ _eclasses_=["python-r1"],
+ IUSE="python_targets_python3_5 " "python_targets_python3_6",
+ RDEPEND="python_targets_python3_5? ( "
+ " dev-lang/python:3.5 ) "
+ "python_targets_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ REQUIRED_USE="|| ( python_targets_python3_5 " " python_targets_python3_6 )",
+ ),
+ )
# python-single-r1 with one implementation does not use PST
self.assertNoReport(
self.check,
- self.mk_pkg(_eclasses_=['python-single-r1'],
- IUSE='python_targets_python3_5',
- RDEPEND='python_targets_python3_5? ( '
- ' dev-lang/python:3.5 )',
- REQUIRED_USE='python_targets_python3_5'))
+ self.mk_pkg(
+ _eclasses_=["python-single-r1"],
+ IUSE="python_targets_python3_5",
+ RDEPEND="python_targets_python3_5? ( " " dev-lang/python:3.5 )",
+ REQUIRED_USE="python_targets_python3_5",
+ ),
+ )
self.assertNoReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-single-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6 '
- 'python_single_target_python3_5 '
- 'python_single_target_python3_6',
- RDEPEND='python_single_target_python3_5? ( '
- ' dev-lang/python:3.5 ) '
- 'python_single_target_python3_6? ( '
- ' dev-lang/python:3.6 )',
- REQUIRED_USE='^^ ( python_single_target_python3_5 '
- ' python_single_target_python3_6 ) '
- 'python_single_target_python3_5? ( '
- ' python_targets_python3_5 ) '
- 'python_single_target_python3_6? ( '
- ' python_targets_python3_6 )'))
+ _eclasses_=["python-single-r1"],
+ IUSE="python_targets_python3_5 "
+ "python_targets_python3_6 "
+ "python_single_target_python3_5 "
+ "python_single_target_python3_6",
+ RDEPEND="python_single_target_python3_5? ( "
+ " dev-lang/python:3.5 ) "
+ "python_single_target_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ REQUIRED_USE="^^ ( python_single_target_python3_5 "
+ " python_single_target_python3_6 ) "
+ "python_single_target_python3_5? ( "
+ " python_targets_python3_5 ) "
+ "python_single_target_python3_6? ( "
+ " python_targets_python3_6 )",
+ ),
+ )
self.assertNoReport(
self.check,
- self.mk_pkg(_eclasses_=['python-any-r1'],
- DEPEND='|| ( '
- ' dev-lang/python:3.5 '
- ' dev-lang/python:3.6 )'))
+ self.mk_pkg(
+ _eclasses_=["python-any-r1"],
+ DEPEND="|| ( " " dev-lang/python:3.5 " " dev-lang/python:3.6 )",
+ ),
+ )
self.assertNoReport(
- self.check,
- self.mk_pkg(_eclasses_=['python-any-r1'], DEPEND='dev-lang/python:3.5'))
+ self.check, self.mk_pkg(_eclasses_=["python-any-r1"], DEPEND="dev-lang/python:3.5")
+ )
self.assertNoReport(
self.check,
- self.mk_pkg(_eclasses_=['python-any-r1'],
- BDEPEND='|| ( '
- ' dev-lang/python:3.5 '
- ' dev-lang/python:3.6 )'))
+ self.mk_pkg(
+ _eclasses_=["python-any-r1"],
+ BDEPEND="|| ( " " dev-lang/python:3.5 " " dev-lang/python:3.6 )",
+ ),
+ )
def test_missing_required_use(self):
r = self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6',
- RDEPEND='python_targets_python3_5? ( '
- ' dev-lang/python:3.5 ) '
- 'python_targets_python3_6? ( '
- ' dev-lang/python:3.6 )'))
+ _eclasses_=["python-r1"],
+ IUSE="python_targets_python3_5 " "python_targets_python3_6",
+ RDEPEND="python_targets_python3_5? ( "
+ " dev-lang/python:3.5 ) "
+ "python_targets_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ ),
+ )
assert isinstance(r, python.PythonMissingRequiredUse)
assert 'missing REQUIRED_USE="${PYTHON_REQUIRED_USE}"' in str(r)
@@ -191,93 +212,105 @@ class TestPythonCheck(misc.ReportTestCase):
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6',
- RDEPEND='python_targets_python3_5? ( '
- ' dev-lang/python:3.5 ) '
- 'python_targets_python3_6? ( '
- ' dev-lang/python:3.6 )',
- REQUIRED_USE='|| ( python_targets_python3_5 )')),
- python.PythonMissingRequiredUse)
+ _eclasses_=["python-r1"],
+ IUSE="python_targets_python3_5 " "python_targets_python3_6",
+ RDEPEND="python_targets_python3_5? ( "
+ " dev-lang/python:3.5 ) "
+ "python_targets_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ REQUIRED_USE="|| ( python_targets_python3_5 )",
+ ),
+ ),
+ python.PythonMissingRequiredUse,
+ )
assert isinstance(
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6 '
- 'python_targets_python3_7',
- RDEPEND='python_targets_python3_5? ( '
- ' dev-lang/python:3.5 ) '
- 'python_targets_python3_6? ( '
- ' dev-lang/python:3.6 ) '
- 'python_targets_python3_7? ( '
- ' dev-lang/python:3.7 )',
- REQUIRED_USE='|| ( python_targets_python3_6 '
- ' python_targets_python3_7 )')),
- python.PythonMissingRequiredUse)
+ _eclasses_=["python-r1"],
+ IUSE="python_targets_python3_5 "
+ "python_targets_python3_6 "
+ "python_targets_python3_7",
+ RDEPEND="python_targets_python3_5? ( "
+ " dev-lang/python:3.5 ) "
+ "python_targets_python3_6? ( "
+ " dev-lang/python:3.6 ) "
+ "python_targets_python3_7? ( "
+ " dev-lang/python:3.7 )",
+ REQUIRED_USE="|| ( python_targets_python3_6 " " python_targets_python3_7 )",
+ ),
+ ),
+ python.PythonMissingRequiredUse,
+ )
assert isinstance(
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-single-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6 '
- 'python_single_target_python3_5 '
- 'python_single_target_python3_6',
- RDEPEND='python_single_target_python3_5? ( '
- ' dev-lang/python:3.5 ) '
- 'python_single_target_python3_6? ( '
- ' dev-lang/python:3.6 )')),
- python.PythonMissingRequiredUse)
+ _eclasses_=["python-single-r1"],
+ IUSE="python_targets_python3_5 "
+ "python_targets_python3_6 "
+ "python_single_target_python3_5 "
+ "python_single_target_python3_6",
+ RDEPEND="python_single_target_python3_5? ( "
+ " dev-lang/python:3.5 ) "
+ "python_single_target_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ ),
+ ),
+ python.PythonMissingRequiredUse,
+ )
# incomplete REQUIRED_USE
assert isinstance(
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-single-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6 '
- 'python_single_target_python3_5 '
- 'python_single_target_python3_6',
- RDEPEND='python_single_target_python3_5? ( '
- ' dev-lang/python:3.5 ) '
- 'python_single_target_python3_6? ( '
- ' dev-lang/python:3.6 )',
- REQUIRED_USE='^^ ( python_single_target_python3_5 )')),
- python.PythonMissingRequiredUse)
+ _eclasses_=["python-single-r1"],
+ IUSE="python_targets_python3_5 "
+ "python_targets_python3_6 "
+ "python_single_target_python3_5 "
+ "python_single_target_python3_6",
+ RDEPEND="python_single_target_python3_5? ( "
+ " dev-lang/python:3.5 ) "
+ "python_single_target_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ REQUIRED_USE="^^ ( python_single_target_python3_5 )",
+ ),
+ ),
+ python.PythonMissingRequiredUse,
+ )
# || instead of ^^ in python-single-r1
assert isinstance(
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-single-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6 '
- 'python_single_target_python3_5 '
- 'python_single_target_python3_6',
- RDEPEND='python_single_target_python3_5? ( '
- ' dev-lang/python:3.5 ) '
- 'python_single_target_python3_6? ( '
- ' dev-lang/python:3.6 )',
- REQUIRED_USE='|| ( python_targets_python3_5 '
- ' python_targets_python3_6 )')),
- python.PythonMissingRequiredUse)
+ _eclasses_=["python-single-r1"],
+ IUSE="python_targets_python3_5 "
+ "python_targets_python3_6 "
+ "python_single_target_python3_5 "
+ "python_single_target_python3_6",
+ RDEPEND="python_single_target_python3_5? ( "
+ " dev-lang/python:3.5 ) "
+ "python_single_target_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ REQUIRED_USE="|| ( python_targets_python3_5 " " python_targets_python3_6 )",
+ ),
+ ),
+ python.PythonMissingRequiredUse,
+ )
def test_missing_deps(self):
r = self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6',
- REQUIRED_USE='|| ( python_targets_python3_5 '
- ' python_targets_python3_6 )'))
+ _eclasses_=["python-r1"],
+ IUSE="python_targets_python3_5 " "python_targets_python3_6",
+ REQUIRED_USE="|| ( python_targets_python3_5 " " python_targets_python3_6 )",
+ ),
+ )
assert isinstance(r, python.PythonMissingDeps)
assert 'missing RDEPEND="${PYTHON_DEPS}"' in str(r)
@@ -285,13 +318,12 @@ class TestPythonCheck(misc.ReportTestCase):
r = self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6',
- RDEPEND='python_targets_python3_5? ( '
- ' dev-lang/python:3.5 )',
- REQUIRED_USE='|| ( python_targets_python3_5 '
- ' python_targets_python3_6 )'))
+ _eclasses_=["python-r1"],
+ IUSE="python_targets_python3_5 " "python_targets_python3_6",
+ RDEPEND="python_targets_python3_5? ( " " dev-lang/python:3.5 )",
+ REQUIRED_USE="|| ( python_targets_python3_5 " " python_targets_python3_6 )",
+ ),
+ )
assert isinstance(r, python.PythonMissingDeps)
assert 'missing RDEPEND="${PYTHON_DEPS}"' in str(r)
@@ -301,69 +333,76 @@ class TestPythonCheck(misc.ReportTestCase):
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6',
- RDEPEND='python_targets_python3_5? ( '
- ' dev-foo/bar ) '
- 'python_targets_python3_6? ( '
- ' dev-lang/python:3.6 )',
- REQUIRED_USE='|| ( python_targets_python3_5 '
- ' python_targets_python3_6 )')),
- python.PythonMissingDeps)
+ _eclasses_=["python-r1"],
+ IUSE="python_targets_python3_5 " "python_targets_python3_6",
+ RDEPEND="python_targets_python3_5? ( "
+ " dev-foo/bar ) "
+ "python_targets_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ REQUIRED_USE="|| ( python_targets_python3_5 " " python_targets_python3_6 )",
+ ),
+ ),
+ python.PythonMissingDeps,
+ )
# DEPEND only, RDEPEND missing
assert isinstance(
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6',
- DEPEND='python_targets_python3_5? ( '
- ' dev-lang/python:3.5 ) '
- 'python_targets_python3_6? ( '
- ' dev-lang/python:3.6 )',
- REQUIRED_USE='|| ( python_targets_python3_5 '
- ' python_targets_python3_6 )')),
- python.PythonMissingDeps)
+ _eclasses_=["python-r1"],
+ IUSE="python_targets_python3_5 " "python_targets_python3_6",
+ DEPEND="python_targets_python3_5? ( "
+ " dev-lang/python:3.5 ) "
+ "python_targets_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ REQUIRED_USE="|| ( python_targets_python3_5 " " python_targets_python3_6 )",
+ ),
+ ),
+ python.PythonMissingDeps,
+ )
assert isinstance(
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-single-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6 '
- 'python_single_target_python3_5 '
- 'python_single_target_python3_6',
- REQUIRED_USE='^^ ( python_single_target_python3_5 '
- ' python_single_target_python3_6 ) '
- 'python_single_target_python3_5? ( '
- ' python_targets_python3_5 ) '
- 'python_single_target_python3_6? ( '
- ' python_targets_python3_6 )')),
- python.PythonMissingDeps)
+ _eclasses_=["python-single-r1"],
+ IUSE="python_targets_python3_5 "
+ "python_targets_python3_6 "
+ "python_single_target_python3_5 "
+ "python_single_target_python3_6",
+ REQUIRED_USE="^^ ( python_single_target_python3_5 "
+ " python_single_target_python3_6 ) "
+ "python_single_target_python3_5? ( "
+ " python_targets_python3_5 ) "
+ "python_single_target_python3_6? ( "
+ " python_targets_python3_6 )",
+ ),
+ ),
+ python.PythonMissingDeps,
+ )
# incomplete deps
assert isinstance(
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-single-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6 '
- 'python_single_target_python3_5 '
- 'python_single_target_python3_6',
- RDEPEND='python_single_target_python3_5? ( '
- ' dev-lang/python:3.5 )',
- REQUIRED_USE='^^ ( python_single_target_python3_5 '
- ' python_single_target_python3_6 ) '
- 'python_single_target_python3_5? ( '
- ' python_targets_python3_5 ) '
- 'python_single_target_python3_6? ( '
- ' python_targets_python3_6 )')),
- python.PythonMissingDeps)
+ _eclasses_=["python-single-r1"],
+ IUSE="python_targets_python3_5 "
+ "python_targets_python3_6 "
+ "python_single_target_python3_5 "
+ "python_single_target_python3_6",
+ RDEPEND="python_single_target_python3_5? ( " " dev-lang/python:3.5 )",
+ REQUIRED_USE="^^ ( python_single_target_python3_5 "
+ " python_single_target_python3_6 ) "
+ "python_single_target_python3_5? ( "
+ " python_targets_python3_5 ) "
+ "python_single_target_python3_6? ( "
+ " python_targets_python3_6 )",
+ ),
+ ),
+ python.PythonMissingDeps,
+ )
# check that irrelevant dep with same USE conditional does not wrongly
# satisfy the check
@@ -371,44 +410,50 @@ class TestPythonCheck(misc.ReportTestCase):
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-single-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6 '
- 'python_single_target_python3_5 '
- 'python_single_target_python3_6',
- RDEPEND='python_single_target_python3_5? ( '
- ' dev-foo/bar ) '
- 'python_single_target_python3_6? ( '
- ' dev-lang/python:3.6 )',
- REQUIRED_USE='^^ ( python_single_target_python3_5 '
- ' python_single_target_python3_6 ) '
- 'python_single_target_python3_5? ( '
- ' python_targets_python3_5 ) '
- 'python_single_target_python3_6? ( '
- ' python_targets_python3_6 )')),
- python.PythonMissingDeps)
+ _eclasses_=["python-single-r1"],
+ IUSE="python_targets_python3_5 "
+ "python_targets_python3_6 "
+ "python_single_target_python3_5 "
+ "python_single_target_python3_6",
+ RDEPEND="python_single_target_python3_5? ( "
+ " dev-foo/bar ) "
+ "python_single_target_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ REQUIRED_USE="^^ ( python_single_target_python3_5 "
+ " python_single_target_python3_6 ) "
+ "python_single_target_python3_5? ( "
+ " python_targets_python3_5 ) "
+ "python_single_target_python3_6? ( "
+ " python_targets_python3_6 )",
+ ),
+ ),
+ python.PythonMissingDeps,
+ )
# DEPEND only, RDEPEND missing
assert isinstance(
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-single-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6 '
- 'python_single_target_python3_5 '
- 'python_single_target_python3_6',
- DEPEND='python_single_target_python3_5? ( '
- ' dev-lang/python:3.5 ) '
- 'python_single_target_python3_6? ( '
- ' dev-lang/python:3.6 )',
- REQUIRED_USE='^^ ( python_single_target_python3_5 '
- ' python_single_target_python3_6 ) '
- 'python_single_target_python3_5? ( '
- ' python_targets_python3_5 ) '
- 'python_single_target_python3_6? ( '
- ' python_targets_python3_6 )')),
- python.PythonMissingDeps)
+ _eclasses_=["python-single-r1"],
+ IUSE="python_targets_python3_5 "
+ "python_targets_python3_6 "
+ "python_single_target_python3_5 "
+ "python_single_target_python3_6",
+ DEPEND="python_single_target_python3_5? ( "
+ " dev-lang/python:3.5 ) "
+ "python_single_target_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ REQUIRED_USE="^^ ( python_single_target_python3_5 "
+ " python_single_target_python3_6 ) "
+ "python_single_target_python3_5? ( "
+ " python_targets_python3_5 ) "
+ "python_single_target_python3_6? ( "
+ " python_targets_python3_6 )",
+ ),
+ ),
+ python.PythonMissingDeps,
+ )
# check that the check isn't wrongly satisfied by PYTHON_TARGETS
# in python-single-r1 (PYTHON_SINGLE_TARGET expected)
@@ -416,38 +461,40 @@ class TestPythonCheck(misc.ReportTestCase):
self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-single-r1'],
- IUSE='python_targets_python3_5 '
- 'python_targets_python3_6 '
- 'python_single_target_python3_5 '
- 'python_single_target_python3_6',
- RDEPEND='python_targets_python3_5? ( '
- ' dev-lang/python:3.5 ) '
- 'python_targets_python3_6? ( '
- ' dev-lang/python:3.6 )',
- REQUIRED_USE='^^ ( python_single_target_python3_5 '
- ' python_single_target_python3_6 ) '
- 'python_single_target_python3_5? ( '
- ' python_targets_python3_5 ) '
- 'python_single_target_python3_6? ( '
- ' python_targets_python3_6 )')),
- python.PythonMissingDeps)
+ _eclasses_=["python-single-r1"],
+ IUSE="python_targets_python3_5 "
+ "python_targets_python3_6 "
+ "python_single_target_python3_5 "
+ "python_single_target_python3_6",
+ RDEPEND="python_targets_python3_5? ( "
+ " dev-lang/python:3.5 ) "
+ "python_targets_python3_6? ( "
+ " dev-lang/python:3.6 )",
+ REQUIRED_USE="^^ ( python_single_target_python3_5 "
+ " python_single_target_python3_6 ) "
+ "python_single_target_python3_5? ( "
+ " python_targets_python3_5 ) "
+ "python_single_target_python3_6? ( "
+ " python_targets_python3_6 )",
+ ),
+ ),
+ python.PythonMissingDeps,
+ )
assert isinstance(
- self.assertReport(self.check, self.mk_pkg(_eclasses_=['python-any-r1'])),
- python.PythonMissingDeps)
+ self.assertReport(self.check, self.mk_pkg(_eclasses_=["python-any-r1"])),
+ python.PythonMissingDeps,
+ )
def test_runtime_dep_in_any_r1(self):
r = self.assertReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-any-r1'],
- DEPEND='|| ( '
- ' dev-lang/python:3.5 '
- ' dev-lang/python:3.6 )',
- RDEPEND='|| ( '
- ' dev-lang/python:3.5 '
- ' dev-lang/python:3.6 )'))
+ _eclasses_=["python-any-r1"],
+ DEPEND="|| ( " " dev-lang/python:3.5 " " dev-lang/python:3.6 )",
+ RDEPEND="|| ( " " dev-lang/python:3.5 " " dev-lang/python:3.6 )",
+ ),
+ )
assert isinstance(r, python.PythonRuntimeDepInAnyR1)
assert 'inherits python-any-r1 with RDEPEND="dev-lang/python:3.5"' in str(r)
@@ -455,6 +502,8 @@ class TestPythonCheck(misc.ReportTestCase):
self.assertNoReport(
self.check,
self.mk_pkg(
- _eclasses_=['python-any-r1'],
- DEPEND='dev-lang/python:3.5',
- RDEPEND='!dev-python/pypy3-bin:0'))
+ _eclasses_=["python-any-r1"],
+ DEPEND="dev-lang/python:3.5",
+ RDEPEND="!dev-python/pypy3-bin:0",
+ ),
+ )
diff --git a/tests/checks/test_repo.py b/tests/checks/test_repo.py
index cd685a52..4220e055 100644
--- a/tests/checks/test_repo.py
+++ b/tests/checks/test_repo.py
@@ -17,15 +17,14 @@ class TestRepoDirCheck(misc.Tmpdir, misc.ReportTestCase):
check_kls = repo.RepoDirCheck
def mk_check(self):
- self.repo = FakeRepo(repo_id='repo', location=self.dir)
- options = arghparse.Namespace(
- target_repo=self.repo, cache={'git': False}, gentoo_repo=True)
+ self.repo = FakeRepo(repo_id="repo", location=self.dir)
+ options = arghparse.Namespace(target_repo=self.repo, cache={"git": False}, gentoo_repo=True)
git_addon = addons.git.GitAddon(options)
return repo.RepoDirCheck(options, git_addon=git_addon)
def mk_pkg(self, cpvstr):
pkg = atom.atom(cpvstr)
- filesdir = pjoin(self.repo.location, pkg.category, pkg.package, 'files')
+ filesdir = pjoin(self.repo.location, pkg.category, pkg.package, "files")
os.makedirs(filesdir, exist_ok=True)
return filesdir
@@ -34,100 +33,100 @@ class TestRepoDirCheck(misc.Tmpdir, misc.ReportTestCase):
def test_empty_file(self):
check = self.mk_check()
- bin_path = pjoin(self.repo.location, 'foo')
+ bin_path = pjoin(self.repo.location, "foo")
touch(bin_path)
self.assertNoReport(check, [])
def test_regular_file(self):
check = self.mk_check()
- with open(pjoin(self.repo.location, 'foo'), 'w') as f:
- f.write('bar')
+ with open(pjoin(self.repo.location, "foo"), "w") as f:
+ f.write("bar")
self.assertNoReport(check, [])
def test_unreadable_file(self):
check = self.mk_check()
- with open(pjoin(self.repo.location, 'foo'), 'w') as f:
- f.write('bar')
- with mock.patch('pkgcheck.open') as mocked_open:
- mocked_open.side_effect = IOError('fake exception')
+ with open(pjoin(self.repo.location, "foo"), "w") as f:
+ f.write("bar")
+ with mock.patch("pkgcheck.open") as mocked_open:
+ mocked_open.side_effect = IOError("fake exception")
self.assertNoReport(check, [])
def test_ignored_root_dirs(self):
for d in self.check_kls.ignored_root_dirs:
check = self.mk_check()
- bin_path = pjoin(self.repo.location, d, 'foo')
+ bin_path = pjoin(self.repo.location, d, "foo")
os.makedirs(os.path.dirname(bin_path))
- with open(bin_path, 'wb') as f:
- f.write(b'\xd3\xad\xbe\xef')
+ with open(bin_path, "wb") as f:
+ f.write(b"\xd3\xad\xbe\xef")
self.assertNoReport(check, [])
def test_null_bytes(self):
check = self.mk_check()
- with open(pjoin(self.repo.location, 'foo'), 'wb') as f:
- f.write(b'foo\x00\xffbar')
+ with open(pjoin(self.repo.location, "foo"), "wb") as f:
+ f.write(b"foo\x00\xffbar")
r = self.assertReport(check, [])
assert isinstance(r, repo.BinaryFile)
- assert r.path == 'foo'
+ assert r.path == "foo"
assert "'foo'" in str(r)
def test_root_dir_binary(self):
check = self.mk_check()
- bin_path = pjoin(self.repo.location, 'foo')
- with open(bin_path, 'wb') as f:
- f.write(b'\xd3\xad\xbe\xef')
+ bin_path = pjoin(self.repo.location, "foo")
+ with open(bin_path, "wb") as f:
+ f.write(b"\xd3\xad\xbe\xef")
r = self.assertReport(check, [])
assert isinstance(r, repo.BinaryFile)
- assert r.path == 'foo'
+ assert r.path == "foo"
assert "'foo'" in str(r)
def test_ebuild_filesdir_binary(self):
check = self.mk_check()
- filesdir = self.mk_pkg('dev-util/foo')
- with open(pjoin(filesdir, 'foo'), 'wb') as f:
- f.write(b'\xd3\xad\xbe\xef')
+ filesdir = self.mk_pkg("dev-util/foo")
+ with open(pjoin(filesdir, "foo"), "wb") as f:
+ f.write(b"\xd3\xad\xbe\xef")
r = self.assertReport(check, [])
assert isinstance(r, repo.BinaryFile)
- assert r.path == 'dev-util/foo/files/foo'
+ assert r.path == "dev-util/foo/files/foo"
assert "'dev-util/foo/files/foo'" in str(r)
def test_gitignore(self):
# distfiles located in deprecated in-tree location are reported by default
check = self.mk_check()
- distfiles = pjoin(self.repo.location, 'distfiles')
+ distfiles = pjoin(self.repo.location, "distfiles")
os.mkdir(distfiles)
- with open(pjoin(distfiles, 'foo-0.tar.gz'), 'wb') as f:
- f.write(b'\xd3\xad\xbe\xef')
+ with open(pjoin(distfiles, "foo-0.tar.gz"), "wb") as f:
+ f.write(b"\xd3\xad\xbe\xef")
r = self.assertReport(check, [])
assert isinstance(r, repo.BinaryFile)
assert "distfiles/foo-0.tar.gz" in str(r)
# but results are suppressed if a matching git ignore entry exists
- for ignore_file in ('.gitignore', '.git/info/exclude'):
+ for ignore_file in (".gitignore", ".git/info/exclude"):
path = pjoin(self.repo.location, ignore_file)
ensure_dirs(os.path.dirname(path))
- with open(path, 'w') as f:
- f.write('/distfiles/')
+ with open(path, "w") as f:
+ f.write("/distfiles/")
self.assertNoReport(self.mk_check(), [])
os.unlink(path)
def test_non_utf8_encodings(self):
# non-english languages courtesy of google translate mangling
langs = (
- ("example text that shouldn't trigger", 'ascii'),
- ('نص المثال الذي لا ينبغي أن يؤدي', 'cp1256'), # arabic
- ('пример текста, который не должен срабатывать', 'koi8_r'), # russian
- ('उदाहरण पाठ जो ट्रिगर नहीं होना चाहिए', 'utf-16'), # hindi
- ('مثال کے متن جو ٹرگر نہ ہوں۔', 'utf-16'), # urdu
- ('ဖြစ်ပေါ်မပေးသင့်ကြောင်းဥပမာစာသား', 'utf-32'), # burmese
- ('उदाहरण पाठ जुन ट्रिगर हुँदैन', 'utf-32'), # nepali
- ('トリガーするべきではないテキストの例', 'shift_jis'), # japanese
- ('트리거해서는 안되는 예제 텍스트', 'cp949'), # korean
- ('不应触发的示例文本', 'gb2312'), # simplified chinese
- ('不應觸發的示例文本', 'gb18030'), # traditional chinese
+ ("example text that shouldn't trigger", "ascii"),
+ ("نص المثال الذي لا ينبغي أن يؤدي", "cp1256"), # arabic
+ ("пример текста, который не должен срабатывать", "koi8_r"), # russian
+ ("उदाहरण पाठ जो ट्रिगर नहीं होना चाहिए", "utf-16"), # hindi
+ ("مثال کے متن جو ٹرگر نہ ہوں۔", "utf-16"), # urdu
+ ("ဖြစ်ပေါ်မပေးသင့်ကြောင်းဥပမာစာသား", "utf-32"), # burmese
+ ("उदाहरण पाठ जुन ट्रिगर हुँदैन", "utf-32"), # nepali
+ ("トリガーするべきではないテキストの例", "shift_jis"), # japanese
+ ("트리거해서는 안되는 예제 텍스트", "cp949"), # korean
+ ("不应触发的示例文本", "gb2312"), # simplified chinese
+ ("不應觸發的示例文本", "gb18030"), # traditional chinese
)
for text, encoding in langs:
check = self.mk_check()
- with open(pjoin(self.repo.location, 'foo'), 'wb') as f:
+ with open(pjoin(self.repo.location, "foo"), "wb") as f:
data = text.encode(encoding)
f.write(data)
self.assertNoReport(check, [])
diff --git a/tests/checks/test_repo_metadata.py b/tests/checks/test_repo_metadata.py
index 2221e283..ff550d7d 100644
--- a/tests/checks/test_repo_metadata.py
+++ b/tests/checks/test_repo_metadata.py
@@ -16,24 +16,25 @@ class TestPackageUpdatesCheck(misc.Tmpdir, misc.ReportTestCase):
def mk_check(self, pkgs=(), **kwargs):
# TODO: switch to using a repo fixture when available
repo_dir = pjoin(self.dir, misc.random_str())
- os.makedirs(pjoin(repo_dir, 'metadata'))
- with open(pjoin(repo_dir, 'metadata', 'layout.conf'), 'w') as f:
- f.write('masters =\n')
+ os.makedirs(pjoin(repo_dir, "metadata"))
+ with open(pjoin(repo_dir, "metadata", "layout.conf"), "w") as f:
+ f.write("masters =\n")
- os.makedirs(pjoin(repo_dir, 'profiles', 'updates'))
- with open(pjoin(repo_dir, 'profiles', 'repo_name'), 'w') as f:
- f.write('fake\n')
+ os.makedirs(pjoin(repo_dir, "profiles", "updates"))
+ with open(pjoin(repo_dir, "profiles", "repo_name"), "w") as f:
+ f.write("fake\n")
for filename, updates in kwargs.items():
- with open(pjoin(repo_dir, 'profiles', 'updates', filename), 'w') as f:
- f.write('\n'.join(updates))
+ with open(pjoin(repo_dir, "profiles", "updates", filename), "w") as f:
+ f.write("\n".join(updates))
for pkg in pkgs:
pkg = FakePkg(pkg)
pkg_path = pjoin(
- repo_dir, pkg.category, pkg.package, f'{pkg.package}-{pkg.fullver}.ebuild')
+ repo_dir, pkg.category, pkg.package, f"{pkg.package}-{pkg.fullver}.ebuild"
+ )
os.makedirs(os.path.dirname(pkg_path), exist_ok=True)
- with open(pkg_path, 'w') as f:
- f.write('SLOT=0\n')
+ with open(pkg_path, "w") as f:
+ f.write("SLOT=0\n")
repo = UnconfiguredTree(repo_dir)
options = arghparse.Namespace(target_repo=repo, search_repo=repo)
@@ -44,87 +45,91 @@ class TestPackageUpdatesCheck(misc.Tmpdir, misc.ReportTestCase):
self.assertNoReport(self.mk_check(), [])
# empty file
- updates = {'1Q-2020': []}
+ updates = {"1Q-2020": []}
self.assertNoReport(self.mk_check(**updates), [])
def test_bad_update_filenames(self):
# only files named using the format [1-4]Q-[YYYY] are allowed
- updates = {'foobar': ['blah']}
+ updates = {"foobar": ["blah"]}
r = self.assertReport(self.mk_check(**updates), [])
assert isinstance(r, repo_metadata.BadPackageUpdate)
assert "incorrectly named update file: 'foobar'" in str(r)
- updates = {'5Q-2020': ['blah']}
+ updates = {"5Q-2020": ["blah"]}
r = self.assertReport(self.mk_check(**updates), [])
assert isinstance(r, repo_metadata.BadPackageUpdate)
assert "incorrectly named update file: '5Q-2020'" in str(r)
# hidden files will be flagged
- updates = {'.1Q-2020.swp': ['blah']}
+ updates = {".1Q-2020.swp": ["blah"]}
r = self.assertReport(self.mk_check(**updates), [])
assert isinstance(r, repo_metadata.BadPackageUpdate)
assert "incorrectly named update file: '.1Q-2020.swp'" in str(r)
def test_empty_line(self):
- updates = {'1Q-2020': [' ']}
+ updates = {"1Q-2020": [" "]}
r = self.assertReport(self.mk_check(**updates), [])
assert isinstance(r, repo_metadata.BadPackageUpdate)
assert "file '1Q-2020': empty line 1" in str(r)
def test_extra_whitespace(self):
- pkgs = ('dev-util/foo-0', 'dev-util/bar-1')
- for update in (' move dev-util/foo dev-util/bar', # prefix
- 'move dev-util/foo dev-util/bar '): # suffix
- updates = {'1Q-2020': [update]}
+ pkgs = ("dev-util/foo-0", "dev-util/bar-1")
+ for update in (
+ " move dev-util/foo dev-util/bar", # prefix
+ "move dev-util/foo dev-util/bar ",
+ ): # suffix
+ updates = {"1Q-2020": [update]}
r = self.assertReport(self.mk_check(pkgs=pkgs, **updates), [])
assert isinstance(r, repo_metadata.BadPackageUpdate)
- assert 'extra whitespace' in str(r)
- assert 'on line 1' in str(r)
+ assert "extra whitespace" in str(r)
+ assert "on line 1" in str(r)
def test_old_pkg_update(self):
- pkgs = ('dev-util/blah-0', 'dev-libs/foon-1')
- for update in ('move dev-util/foo dev-util/bar', # old pkg move
- 'slotmove dev-util/bar 0 1'): # old slot move
- updates = {'1Q-2020': [update]}
+ pkgs = ("dev-util/blah-0", "dev-libs/foon-1")
+ for update in (
+ "move dev-util/foo dev-util/bar", # old pkg move
+ "slotmove dev-util/bar 0 1",
+ ): # old slot move
+ updates = {"1Q-2020": [update]}
r = self.assertReport(self.mk_check(pkgs=pkgs, **updates), [])
assert isinstance(r, repo_metadata.OldPackageUpdate)
- assert r.pkg == 'dev-util/bar'
+ assert r.pkg == "dev-util/bar"
assert "'dev-util/bar' unavailable" in str(r)
def test_old_multimove_pkg_update(self):
- update = ['move dev-util/foo dev-util/bar', 'move dev-util/bar dev-util/blah']
- pkgs = ('dev-util/blaz-0', 'dev-libs/foon-1')
- updates = {'1Q-2020': update}
+ update = ["move dev-util/foo dev-util/bar", "move dev-util/bar dev-util/blah"]
+ pkgs = ("dev-util/blaz-0", "dev-libs/foon-1")
+ updates = {"1Q-2020": update}
r = self.assertReport(self.mk_check(pkgs=pkgs, **updates), [])
assert isinstance(r, repo_metadata.OldMultiMovePackageUpdate)
- assert r.pkg == 'dev-util/blah'
- assert r.moves == ('dev-util/foo', 'dev-util/bar', 'dev-util/blah')
+ assert r.pkg == "dev-util/blah"
+ assert r.moves == ("dev-util/foo", "dev-util/bar", "dev-util/blah")
assert "'dev-util/blah' unavailable" in str(r)
def test_multimove_pkg_update(self):
- update = ['move dev-util/foo dev-util/bar', 'move dev-util/bar dev-util/blah']
- pkgs = ('dev-util/blah-0', 'dev-libs/foon-1')
- updates = {'1Q-2020': update}
+ update = ["move dev-util/foo dev-util/bar", "move dev-util/bar dev-util/blah"]
+ pkgs = ("dev-util/blah-0", "dev-libs/foon-1")
+ updates = {"1Q-2020": update}
r = self.assertReport(self.mk_check(pkgs=pkgs, **updates), [])
assert isinstance(r, repo_metadata.MultiMovePackageUpdate)
- assert r.pkg == 'dev-util/foo'
- assert r.moves == ('dev-util/foo', 'dev-util/bar', 'dev-util/blah')
+ assert r.pkg == "dev-util/foo"
+ assert r.moves == ("dev-util/foo", "dev-util/bar", "dev-util/blah")
assert "'dev-util/foo': multi-move update" in str(r)
def test_move_to_self_pkg_update(self):
- update = ['move dev-util/foo dev-util/foo']
- pkgs = ('dev-util/foo-0',)
- updates = {'1Q-2020': update}
+ update = ["move dev-util/foo dev-util/foo"]
+ pkgs = ("dev-util/foo-0",)
+ updates = {"1Q-2020": update}
r = self.assertReport(self.mk_check(pkgs=pkgs, **updates), [])
assert isinstance(r, repo_metadata.RedundantPackageUpdate)
- assert r.updates == ('move', 'dev-util/foo', 'dev-util/foo')
+ assert r.updates == ("move", "dev-util/foo", "dev-util/foo")
assert "update line moves to the same package/slot" in str(r)
def test_slot_move_to_self_pkg_update(self):
- update = ['slotmove dev-util/foo 0 0']
- pkgs = ('dev-util/foo-0',)
- updates = {'1Q-2020': update}
+ update = ["slotmove dev-util/foo 0 0"]
+ pkgs = ("dev-util/foo-0",)
+ updates = {"1Q-2020": update}
r = self.assertReport(self.mk_check(pkgs=pkgs, **updates), [])
assert isinstance(r, repo_metadata.RedundantPackageUpdate)
- assert r.updates == ('slotmove', 'dev-util/foo', '0', '0')
+ assert r.updates == ("slotmove", "dev-util/foo", "0", "0")
assert "update line moves to the same package/slot" in str(r)
diff --git a/tests/checks/test_stablereq.py b/tests/checks/test_stablereq.py
index b51bf9bc..2e181e57 100644
--- a/tests/checks/test_stablereq.py
+++ b/tests/checks/test_stablereq.py
@@ -21,17 +21,17 @@ class TestStableRequestCheck(ReportTestCase):
# initialize parent repo
self.parent_git_repo = make_git_repo()
- self.parent_repo = make_repo(self.parent_git_repo.path, repo_id='gentoo')
- self.parent_git_repo.add_all('initial commit')
+ self.parent_repo = make_repo(self.parent_git_repo.path, repo_id="gentoo")
+ self.parent_git_repo.add_all("initial commit")
# create a stub pkg and commit it
- self.parent_repo.create_ebuild('cat/pkg-0')
- self.parent_git_repo.add_all('cat/pkg-0')
+ self.parent_repo.create_ebuild("cat/pkg-0")
+ self.parent_git_repo.add_all("cat/pkg-0")
# initialize child repo
self.child_git_repo = make_git_repo()
- self.child_git_repo.run(['git', 'remote', 'add', 'origin', self.parent_git_repo.path])
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_git_repo.run(['git', 'remote', 'set-head', 'origin', 'main'])
+ self.child_git_repo.run(["git", "remote", "add", "origin", self.parent_git_repo.path])
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_git_repo.run(["git", "remote", "set-head", "origin", "main"])
self.child_repo = make_repo(self.child_git_repo.path)
def init_check(self, options=None, future=0, stable_time=None):
@@ -44,50 +44,57 @@ class TestStableRequestCheck(ReportTestCase):
def _options(self, stable_time=None, **kwargs):
args = [
- 'scan', '-q', '--cache-dir', self.cache_dir,
- '--repo', self.child_repo.location,
+ "scan",
+ "-q",
+ "--cache-dir",
+ self.cache_dir,
+ "--repo",
+ self.child_repo.location,
]
if stable_time is not None:
- args.extend(['--stabletime', str(stable_time)])
+ args.extend(["--stabletime", str(stable_time)])
options, _ = self._tool.parse_args(args)
return options
def test_no_git_support(self):
options = self._options()
- options.cache['git'] = False
- with pytest.raises(SkipCheck, match='git cache support required'):
+ options.cache["git"] = False
+ with pytest.raises(SkipCheck, match="git cache support required"):
self.init_check(options)
def test_no_stable_keywords(self):
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['~amd64'])
- self.parent_git_repo.add_all('cat/pkg-1')
- self.parent_repo.create_ebuild('cat/pkg-2', keywords=['~amd64'])
- self.parent_git_repo.add_all('cat/pkg-2')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["~amd64"])
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.parent_repo.create_ebuild("cat/pkg-2", keywords=["~amd64"])
+ self.parent_git_repo.add_all("cat/pkg-2")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
self.init_check()
self.assertNoReport(self.check, self.source)
def test_uncommitted_local_ebuild(self):
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['amd64'])
- self.parent_git_repo.add_all('cat/pkg-1')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
- self.child_repo.create_ebuild('cat/pkg-2', keywords=['~amd64'])
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["amd64"])
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
+ self.child_repo.create_ebuild("cat/pkg-2", keywords=["~amd64"])
self.init_check(future=30)
self.assertNoReport(self.check, self.source)
- @pytest.mark.parametrize(("stable_time", "less_days", "more_days"), (
- pytest.param(None, (0, 1, 10, 20, 29), (30, 31), id="stable_time=unset"),
- pytest.param(1, (0,), (1, 10), id="stable_time=1"),
- pytest.param(14, (0, 1, 10, 13), (14, 15, 30), id="stable_time=14"),
- pytest.param(30, (0, 1, 10, 20, 29), (30, 31), id="stable_time=30"),
- pytest.param(100, (98, 99), (100, 101), id="stable_time=100"),
- ))
+ @pytest.mark.parametrize(
+ ("stable_time", "less_days", "more_days"),
+ (
+ pytest.param(None, (0, 1, 10, 20, 29), (30, 31), id="stable_time=unset"),
+ pytest.param(1, (0,), (1, 10), id="stable_time=1"),
+ pytest.param(14, (0, 1, 10, 13), (14, 15, 30), id="stable_time=14"),
+ pytest.param(30, (0, 1, 10, 20, 29), (30, 31), id="stable_time=30"),
+ pytest.param(100, (98, 99), (100, 101), id="stable_time=100"),
+ ),
+ )
def test_existing_stable_keywords(self, stable_time, less_days, more_days):
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['amd64'])
- self.parent_git_repo.add_all('cat/pkg-1')
- self.parent_repo.create_ebuild('cat/pkg-2', keywords=['~amd64'])
- self.parent_git_repo.add_all('cat/pkg-2')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["amd64"])
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.parent_repo.create_ebuild("cat/pkg-2", keywords=["~amd64"])
+ self.parent_git_repo.add_all("cat/pkg-2")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
# packages are not old enough to trigger any results
for future in less_days:
@@ -98,74 +105,74 @@ class TestStableRequestCheck(ReportTestCase):
for future in more_days:
self.init_check(future=future, stable_time=stable_time)
r = self.assertReport(self.check, self.source)
- expected = StableRequest('0', ['~amd64'], future, pkg=VersionedCPV('cat/pkg-2'))
+ expected = StableRequest("0", ["~amd64"], future, pkg=VersionedCPV("cat/pkg-2"))
assert r == expected
def test_multislot_with_unstable_slot(self):
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['amd64'])
- self.parent_git_repo.add_all('cat/pkg-1')
- self.parent_repo.create_ebuild('cat/pkg-2', keywords=['~amd64'], slot='1')
- self.parent_git_repo.add_all('cat/pkg-2')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["amd64"])
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.parent_repo.create_ebuild("cat/pkg-2", keywords=["~amd64"], slot="1")
+ self.parent_git_repo.add_all("cat/pkg-2")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
self.init_check(future=30)
r = self.assertReport(self.check, self.source)
- expected = StableRequest('1', ['~amd64'], 30, pkg=VersionedCPV('cat/pkg-2'))
+ expected = StableRequest("1", ["~amd64"], 30, pkg=VersionedCPV("cat/pkg-2"))
assert r == expected
def test_moved_category(self):
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['amd64'])
- self.parent_git_repo.add_all('cat/pkg-1')
- self.parent_repo.create_ebuild('cat/pkg-2', keywords=['~amd64'])
- self.parent_git_repo.add_all('cat/pkg-2')
- self.parent_git_repo.move('cat', 'newcat')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["amd64"])
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.parent_repo.create_ebuild("cat/pkg-2", keywords=["~amd64"])
+ self.parent_git_repo.add_all("cat/pkg-2")
+ self.parent_git_repo.move("cat", "newcat")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
self.init_check(future=30)
r = self.assertReport(self.check, self.source)
- expected = StableRequest('0', ['~amd64'], 30, pkg=VersionedCPV('newcat/pkg-2'))
+ expected = StableRequest("0", ["~amd64"], 30, pkg=VersionedCPV("newcat/pkg-2"))
assert r == expected
def test_moved_package(self):
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['amd64'])
- self.parent_git_repo.add_all('cat/pkg-1')
- self.parent_repo.create_ebuild('cat/pkg-2', keywords=['~amd64'])
- self.parent_git_repo.add_all('cat/pkg-2')
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["amd64"])
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.parent_repo.create_ebuild("cat/pkg-2", keywords=["~amd64"])
+ self.parent_git_repo.add_all("cat/pkg-2")
# rename pkg and commit results
path = self.parent_git_repo.path
- new_pkg_dir = pjoin(path, 'cat/newpkg')
- os.rename(pjoin(path, 'cat/pkg'), new_pkg_dir)
+ new_pkg_dir = pjoin(path, "cat/newpkg")
+ os.rename(pjoin(path, "cat/pkg"), new_pkg_dir)
for i, f in enumerate(sorted(os.listdir(new_pkg_dir))):
- os.rename(pjoin(new_pkg_dir, f), pjoin(new_pkg_dir, f'newpkg-{i}.ebuild'))
+ os.rename(pjoin(new_pkg_dir, f), pjoin(new_pkg_dir, f"newpkg-{i}.ebuild"))
self.parent_git_repo.add_all()
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
self.init_check(future=30)
r = self.assertReport(self.check, self.source)
- expected = StableRequest('0', ['~amd64'], 30, pkg=VersionedCPV('cat/newpkg-2'))
+ expected = StableRequest("0", ["~amd64"], 30, pkg=VersionedCPV("cat/newpkg-2"))
assert r == expected
def test_renamed_ebuild(self):
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['amd64'])
- self.parent_git_repo.add_all('cat/pkg-1')
- self.parent_repo.create_ebuild('cat/pkg-2_rc1', keywords=['~amd64'])
- self.parent_git_repo.add_all('cat/pkg-2_rc1')
- self.parent_git_repo.move('cat/pkg/pkg-2_rc1.ebuild', 'cat/pkg/pkg-2.ebuild')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["amd64"])
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.parent_repo.create_ebuild("cat/pkg-2_rc1", keywords=["~amd64"])
+ self.parent_git_repo.add_all("cat/pkg-2_rc1")
+ self.parent_git_repo.move("cat/pkg/pkg-2_rc1.ebuild", "cat/pkg/pkg-2.ebuild")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
self.init_check(future=30)
r = self.assertReport(self.check, self.source)
- expected = StableRequest('0', ['~amd64'], 30, pkg=VersionedCPV('cat/pkg-2'))
+ expected = StableRequest("0", ["~amd64"], 30, pkg=VersionedCPV("cat/pkg-2"))
assert r == expected
def test_modified_ebuild(self):
- self.parent_repo.create_ebuild('cat/pkg-1', keywords=['amd64'])
- self.parent_git_repo.add_all('cat/pkg-1')
- self.parent_repo.create_ebuild('cat/pkg-2', keywords=['~amd64'])
- self.parent_git_repo.add_all('cat/pkg-2')
- with open(pjoin(self.parent_git_repo.path, 'cat/pkg/pkg-2.ebuild'), 'a') as f:
- f.write('# comment\n')
- self.parent_git_repo.add_all('cat/pkg-2: add comment')
- self.child_git_repo.run(['git', 'pull', 'origin', 'main'])
+ self.parent_repo.create_ebuild("cat/pkg-1", keywords=["amd64"])
+ self.parent_git_repo.add_all("cat/pkg-1")
+ self.parent_repo.create_ebuild("cat/pkg-2", keywords=["~amd64"])
+ self.parent_git_repo.add_all("cat/pkg-2")
+ with open(pjoin(self.parent_git_repo.path, "cat/pkg/pkg-2.ebuild"), "a") as f:
+ f.write("# comment\n")
+ self.parent_git_repo.add_all("cat/pkg-2: add comment")
+ self.child_git_repo.run(["git", "pull", "origin", "main"])
self.init_check(future=30)
r = self.assertReport(self.check, self.source)
- expected = StableRequest('0', ['~amd64'], 30, pkg=VersionedCPV('cat/pkg-2'))
+ expected = StableRequest("0", ["~amd64"], 30, pkg=VersionedCPV("cat/pkg-2"))
assert r == expected
diff --git a/tests/checks/test_whitespace.py b/tests/checks/test_whitespace.py
index bc61998c..f90495b6 100644
--- a/tests/checks/test_whitespace.py
+++ b/tests/checks/test_whitespace.py
@@ -15,7 +15,6 @@ class WhitespaceCheckTest(misc.ReportTestCase):
class TestWhitespaceFound(WhitespaceCheckTest):
-
def test_leading(self):
fake_src = [
"# This is our first fake ebuild\n",
@@ -27,7 +26,7 @@ class TestWhitespaceFound(WhitespaceCheckTest):
r = self.assertReport(self.check, fake_pkg)
assert isinstance(r, whitespace.WhitespaceFound)
assert r.lines == (2,)
- assert 'leading whitespace' in str(r)
+ assert "leading whitespace" in str(r)
def test_trailing(self):
fake_src = [
@@ -40,11 +39,10 @@ class TestWhitespaceFound(WhitespaceCheckTest):
r = self.assertReport(self.check, fake_pkg)
assert isinstance(r, whitespace.WhitespaceFound)
assert r.lines == (2,)
- assert 'trailing whitespace' in str(r)
+ assert "trailing whitespace" in str(r)
class TestWrongIndentFound(WhitespaceCheckTest):
-
def test_it(self):
fake_src = [
"# This is our first fake ebuild\n",
@@ -56,11 +54,10 @@ class TestWrongIndentFound(WhitespaceCheckTest):
r = self.assertReport(self.check, fake_pkg)
assert isinstance(r, whitespace.WrongIndentFound)
assert r.lines == (2,)
- assert 'whitespace in indentation' in str(r)
+ assert "whitespace in indentation" in str(r)
class TestDoubleEmptyLine(WhitespaceCheckTest):
-
def test_it(self):
fake_src = [
"# This is our first fake ebuild\n",
@@ -73,11 +70,10 @@ class TestDoubleEmptyLine(WhitespaceCheckTest):
r = self.assertReport(self.check, fake_pkg)
assert isinstance(r, whitespace.DoubleEmptyLine)
assert r.lines == (3,)
- assert 'unneeded empty line' in str(r)
+ assert "unneeded empty line" in str(r)
class TestNoNewLineOnEnd(WhitespaceCheckTest):
-
def test_it(self):
fake_src = [
"# This is our first fake ebuild\n",
@@ -87,11 +83,10 @@ class TestNoNewLineOnEnd(WhitespaceCheckTest):
r = self.assertReport(self.check, fake_pkg)
assert isinstance(r, whitespace.NoFinalNewline)
- assert 'lacks an ending newline' in str(r)
+ assert "lacks an ending newline" in str(r)
class TestTrailingNewLineOnEnd(WhitespaceCheckTest):
-
def test_it(self):
fake_src = [
"# This is our first fake ebuild\n",
@@ -102,43 +97,43 @@ class TestTrailingNewLineOnEnd(WhitespaceCheckTest):
r = self.assertReport(self.check, fake_pkg)
assert isinstance(r, whitespace.TrailingEmptyLine)
- assert 'trailing blank line(s)' in str(r)
+ assert "trailing blank line(s)" in str(r)
def generate_whitespace_data():
"""Generate bad whitespace list for the current python version."""
all_whitespace_chars = set(
- re.findall(r'\s', ''.join(chr(c) for c in range(sys.maxunicode + 1))))
- allowed_whitespace_chars = {'\t', '\n', ' '}
+ re.findall(r"\s", "".join(chr(c) for c in range(sys.maxunicode + 1)))
+ )
+ allowed_whitespace_chars = {"\t", "\n", " "}
bad_whitespace_chars = tuple(sorted(all_whitespace_chars - allowed_whitespace_chars))
return whitespace.WhitespaceData(unicodedata.unidata_version, bad_whitespace_chars)
class TestBadWhitespaceCharacter(WhitespaceCheckTest):
-
def test_outdated_bad_whitespace_chars(self):
"""Check if the hardcoded bad whitespace character list is outdated."""
updated_whitespace_data = generate_whitespace_data()
if updated_whitespace_data.unicode_version != whitespace.whitespace_data.unicode_version:
- assert updated_whitespace_data.chars == whitespace.whitespace_data.chars, \
- f'outdated character list for Unicode version {unicodedata.unidata_version}'
+ assert (
+ updated_whitespace_data.chars == whitespace.whitespace_data.chars
+ ), f"outdated character list for Unicode version {unicodedata.unidata_version}"
def test_bad_whitespace_chars(self):
for char in whitespace.whitespace_data.chars:
fake_src = [
- 'src_prepare() {\n',
+ "src_prepare() {\n",
f'\tcd "${{S}}"/cpp ||{char}die\n',
- '}\n',
+ "}\n",
]
fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
r = self.assertReport(self.check, fake_pkg)
assert isinstance(r, whitespace.BadWhitespaceCharacter)
- assert f'bad whitespace character {repr(char)} on line 2' in str(r)
+ assert f"bad whitespace character {repr(char)} on line 2" in str(r)
class TestMultipleChecks(WhitespaceCheckTest):
-
def test_it(self):
fake_src = [
"# This is our first fake ebuild\n",