* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/
@ 2024-07-20 15:37 Arthur Zamarin
0 siblings, 0 replies; 5+ messages in thread
From: Arthur Zamarin @ 2024-07-20 15:37 UTC (permalink / raw
To: gentoo-commits
commit: 3a4a1f3b000d297f6bc9ab6b44e68d991e74b28c
Author: Lucio Sauer <watermanpaint <AT> posteo <DOT> net>
AuthorDate: Sat Jul 20 15:02:16 2024 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Jul 20 15:37:22 2024 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=3a4a1f3b
tests: add tests for Closes tags with resolution
Signed-off-by: Lucio Sauer <watermanpaint <AT> posteo.net>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
tests/scripts/test_pkgdev_commit.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/tests/scripts/test_pkgdev_commit.py b/tests/scripts/test_pkgdev_commit.py
index ff93db8..04fc16a 100644
--- a/tests/scripts/test_pkgdev_commit.py
+++ b/tests/scripts/test_pkgdev_commit.py
@@ -152,6 +152,36 @@ class TestPkgdevCommitParseArgs:
options, _ = tool.parse_args(["commit", opt, "https://bugs.gentoo.org/2"])
assert options.footer == {("Closes", "https://bugs.gentoo.org/2")}
+ # bug IDs and URLs with good resolutions
+ for opt in ("-c", "--closes"):
+ for values, expected in (
+ (("", "FIXED", "fiXed"), ""),
+ (("PKGREMOVED", "pkgRemovEd"), " (pkgremoved)"),
+ (("OBSOLETE", "obSoleTe"), " (obsolete)"),
+ ):
+ for value in values:
+ for bug in "1", "https://bugs.gentoo.org/1":
+ options, _ = tool.parse_args(["commit", opt, f"{bug}:{value}"])
+ assert options.footer == {
+ ("Closes", f"https://bugs.gentoo.org/1{expected}")
+ }
+
+ # bad bug-resolution pair
+ for opt in ("-c", "--closes"):
+ for value, expected in (
+ (":", "invalid commit tag"),
+ (":1", "invalid commit tag"),
+ (":fixed", "invalid commit tag"),
+ ("1:invalid", "should be one of"),
+ ("https://bugs.gentoo.org/1:invalid", "should be one of"),
+ ):
+ with pytest.raises(SystemExit) as excinfo:
+ options, _ = tool.parse_args(["commit", opt, value])
+ assert excinfo.value.code == 2
+ out, err = capsys.readouterr()
+ assert not out
+ assert expected in err
+
# bad URL
for opt in ("-b", "-c"):
with pytest.raises(SystemExit) as excinfo:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/
@ 2024-01-26 20:22 Arthur Zamarin
0 siblings, 0 replies; 5+ messages in thread
From: Arthur Zamarin @ 2024-01-26 20:22 UTC (permalink / raw
To: gentoo-commits
commit: 97df81b07a9dd8ae9b1b90b260f3c1533ef02ea7
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 26 20:20:35 2024 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jan 26 20:20:35 2024 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=97df81b0
reformat with black 24
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
tests/scripts/test_pkgdev_bugs.py | 3 +-
tests/scripts/test_pkgdev_commit.py | 171 ++++++++++++++++++++++------------
tests/scripts/test_pkgdev_manifest.py | 12 ++-
tests/scripts/test_pkgdev_mask.py | 130 +++++++++++++++++---------
tests/scripts/test_pkgdev_push.py | 36 ++++---
tests/scripts/test_pkgdev_showkw.py | 49 ++++++----
6 files changed, 258 insertions(+), 143 deletions(-)
diff --git a/tests/scripts/test_pkgdev_bugs.py b/tests/scripts/test_pkgdev_bugs.py
index 641e5f0..3a61a89 100644
--- a/tests/scripts/test_pkgdev_bugs.py
+++ b/tests/scripts/test_pkgdev_bugs.py
@@ -51,8 +51,7 @@ class BugsSession:
def __enter__(self):
return self
- def __exit__(self, *_args):
- ...
+ def __exit__(self, *_args): ...
def read(self):
return json.dumps({"id": next(self.counter)}).encode("utf-8")
diff --git a/tests/scripts/test_pkgdev_commit.py b/tests/scripts/test_pkgdev_commit.py
index b2ec4be..ff93db8 100644
--- a/tests/scripts/test_pkgdev_commit.py
+++ b/tests/scripts/test_pkgdev_commit.py
@@ -194,8 +194,10 @@ class TestPkgdevCommit:
def test_empty_repo(self, capsys, repo, make_git_repo):
git_repo = make_git_repo(repo.location, commit=True)
- with patch("sys.argv", self.args), pytest.raises(SystemExit) as excinfo, chdir(
- git_repo.path
+ with (
+ patch("sys.argv", self.args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
):
self.script()
assert excinfo.value.code == 2
@@ -212,9 +214,11 @@ class TestPkgdevCommit:
with open(path, "w") as f:
f.write("commit1")
- with patch("sys.argv", self.args + ["-u", "-F", path]), pytest.raises(
- SystemExit
- ) as excinfo, chdir(git_repo.path):
+ with (
+ patch("sys.argv", self.args + ["-u", "-F", path]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
commit_msg = git_repo.log(["-1", "--pretty=tformat:%B", "HEAD"])
@@ -222,9 +226,12 @@ class TestPkgdevCommit:
repo.create_ebuild("cat/pkg-1")
git_repo.add_all("cat/pkg-1", commit=False)
- with os_environ(GIT_EDITOR="sed -i '1s/1/2/'"), patch(
- "sys.argv", self.args + ["-u", "-t", path]
- ), pytest.raises(SystemExit) as excinfo, chdir(git_repo.path):
+ with (
+ os_environ(GIT_EDITOR="sed -i '1s/1/2/'"),
+ patch("sys.argv", self.args + ["-u", "-t", path]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
commit_msg = git_repo.log(["-1", "--pretty=tformat:%B", "HEAD"])
@@ -251,9 +258,11 @@ class TestPkgdevCommit:
for i, opt in enumerate(["-M", "--message-template"], 1):
repo.create_ebuild(f"cat/pkg-{i}")
git_repo.add_all(f"cat/pkg-{i}", commit=False)
- with patch("sys.argv", self.args + ["-u", opt, path]), pytest.raises(
- SystemExit
- ) as excinfo, chdir(git_repo.path):
+ with (
+ patch("sys.argv", self.args + ["-u", opt, path]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
commit_msg = git_repo.log(["-1", "--pretty=tformat:%B", "HEAD"])
@@ -274,9 +283,11 @@ class TestPkgdevCommit:
for i, opt in enumerate(["-M", "--message-template"], 3):
repo.create_ebuild(f"cat/pkg-{i}")
git_repo.add_all(f"cat/pkg-{i}", commit=False)
- with patch("sys.argv", self.args + ["-u", opt, path]), pytest.raises(
- SystemExit
- ) as excinfo, chdir(git_repo.path):
+ with (
+ patch("sys.argv", self.args + ["-u", opt, path]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
commit_msg = git_repo.log(["-1", "--pretty=tformat:%B", "HEAD"])
@@ -289,9 +300,11 @@ class TestPkgdevCommit:
for i, opt in enumerate(["-M", "--message-template"], 5):
repo.create_ebuild(f"cat/pkg-{i}")
git_repo.add_all(f"cat/pkg-{i}", commit=False)
- with patch("sys.argv", self.args + ["-u", opt, path]), pytest.raises(
- SystemExit
- ) as excinfo, chdir(git_repo.path):
+ with (
+ patch("sys.argv", self.args + ["-u", opt, path]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 2
out, err = capsys.readouterr()
@@ -305,9 +318,11 @@ class TestPkgdevCommit:
with open(ebuild_path, "a+") as f:
f.write("# comment\n")
- with patch("sys.argv", self.args + ["-u", "-m", "msg"]), pytest.raises(
- SystemExit
- ) as excinfo, chdir(git_repo.path):
+ with (
+ patch("sys.argv", self.args + ["-u", "-m", "msg"]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
out, err = capsys.readouterr()
@@ -323,9 +338,11 @@ class TestPkgdevCommit:
with open(ebuild_path, "a+") as f:
f.write("# comment\n")
- with patch("sys.argv", self.args + ["-u", "-m", "prefix: msg"]), pytest.raises(
- SystemExit
- ) as excinfo, chdir(git_repo.path):
+ with (
+ patch("sys.argv", self.args + ["-u", "-m", "prefix: msg"]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
out, err = capsys.readouterr()
@@ -341,9 +358,12 @@ class TestPkgdevCommit:
with open(ebuild_path, "a+") as f:
f.write("# comment\n")
- with os_environ(GIT_EDITOR="sed -i '1s/$/commit/'"), patch(
- "sys.argv", self.args + ["-u"]
- ), pytest.raises(SystemExit) as excinfo, chdir(git_repo.path):
+ with (
+ os_environ(GIT_EDITOR="sed -i '1s/$/commit/'"),
+ patch("sys.argv", self.args + ["-u"]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
out, err = capsys.readouterr()
@@ -358,9 +378,11 @@ class TestPkgdevCommit:
git_repo.add_all("cat/pkg-0")
def commit():
- with patch("sys.argv", self.args + ["-a", "-m", "msg"]), pytest.raises(
- SystemExit
- ) as excinfo, chdir(git_repo.path):
+ with (
+ patch("sys.argv", self.args + ["-a", "-m", "msg"]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
out, err = capsys.readouterr()
@@ -441,9 +463,12 @@ class TestPkgdevCommit:
git_repo.add_all("cat/pkg-0")
def commit():
- with os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"), patch(
- "sys.argv", self.args + ["-a"]
- ), pytest.raises(SystemExit) as excinfo, chdir(git_repo.path):
+ with (
+ os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"),
+ patch("sys.argv", self.args + ["-a"]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
out, err = capsys.readouterr()
@@ -592,9 +617,12 @@ class TestPkgdevCommit:
git_repo.add_all("cat/pkg-0")
def commit():
- with os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"), patch(
- "sys.argv", self.args + ["-a"]
- ), pytest.raises(SystemExit) as excinfo, chdir(git_repo.path):
+ with (
+ os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"),
+ patch("sys.argv", self.args + ["-a"]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
out, err = capsys.readouterr()
@@ -670,9 +698,12 @@ class TestPkgdevCommit:
git_repo.add_all("cat/pkg-0")
def commit():
- with os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"), patch(
- "sys.argv", self.args + ["-a"]
- ), pytest.raises(SystemExit) as excinfo, chdir(git_repo.path):
+ with (
+ os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"),
+ patch("sys.argv", self.args + ["-a"]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
out, err = capsys.readouterr()
@@ -859,9 +890,12 @@ class TestPkgdevCommit:
git_repo.add_all("cat/pkg-0")
def commit(args):
- with os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"), patch(
- "sys.argv", self.args + args
- ), pytest.raises(SystemExit) as excinfo, chdir(git_repo.path):
+ with (
+ os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"),
+ patch("sys.argv", self.args + args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
out, err = capsys.readouterr()
@@ -886,8 +920,10 @@ class TestPkgdevCommit:
git_repo.add_all("cat/pkg-0")
def commit(args):
- with patch("sys.argv", self.args + args), pytest.raises(SystemExit) as excinfo, chdir(
- git_repo.path
+ with (
+ patch("sys.argv", self.args + args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
):
self.script()
assert excinfo.value.code == 0
@@ -928,8 +964,10 @@ class TestPkgdevCommit:
git_repo.add_all("cat/pkg-0")
def commit(args):
- with patch("sys.argv", self.args + args), pytest.raises(SystemExit) as excinfo, chdir(
- git_repo.path
+ with (
+ patch("sys.argv", self.args + args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
):
self.script()
assert excinfo.value.code == 0
@@ -1006,8 +1044,10 @@ class TestPkgdevCommit:
for i, opt in enumerate(["-s", "--scan"], 1):
repo.create_ebuild(f"cat/pkg-{i}")
git_repo.add_all(f"cat/pkg-{i}", commit=False)
- with patch("sys.argv", self.args + [opt]), pytest.raises(SystemExit) as excinfo, chdir(
- git_repo.path
+ with (
+ patch("sys.argv", self.args + [opt]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
):
self.script()
assert excinfo.value.code == 0
@@ -1024,8 +1064,10 @@ class TestPkgdevCommit:
# verify staged changes via `pkgcheck scan` before creating commit
repo.create_ebuild("cat/pkg-1", license="")
git_repo.add_all("cat/pkg-1", commit=False)
- with patch("sys.argv", self.args + ["--scan"]), pytest.raises(SystemExit) as excinfo, chdir(
- git_repo.path
+ with (
+ patch("sys.argv", self.args + ["--scan"]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
):
self.script()
assert excinfo.value.code == 1
@@ -1043,9 +1085,12 @@ class TestPkgdevCommit:
)
# ignore failures to create the commit
- with patch("sys.argv", self.args + ["--scan", "--ask"]), patch(
- "sys.stdin", StringIO("y\n")
- ), pytest.raises(SystemExit) as excinfo, chdir(git_repo.path):
+ with (
+ patch("sys.argv", self.args + ["--scan", "--ask"]),
+ patch("sys.stdin", StringIO("y\n")),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
@@ -1066,9 +1111,11 @@ class TestPkgdevCommit:
git_repo.add_all("cat/pkg-0")
repo.create_ebuild("cat/pkg-1", license="")
git_repo.add_all("cat/pkg-1", commit=False)
- with patch(
- "sys.argv", ["pkgdev", "commit", "--config", config_file] + self.scan_args
- ), pytest.raises(SystemExit) as excinfo, chdir(git_repo.path):
+ with (
+ patch("sys.argv", ["pkgdev", "commit", "--config", config_file] + self.scan_args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
out, err = capsys.readouterr()
assert excinfo.value.code == 1
@@ -1092,9 +1139,11 @@ class TestPkgdevCommit:
git_repo.add_all("cat/pkg-0")
repo.create_ebuild("cat/pkg-1", license="")
git_repo.add_all("cat/pkg-1", commit=False)
- with patch(
- "sys.argv", ["pkgdev", "commit", "--config", config_file] + self.scan_args
- ), pytest.raises(SystemExit) as excinfo, chdir(git_repo.path):
+ with (
+ patch("sys.argv", ["pkgdev", "commit", "--config", config_file] + self.scan_args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
+ ):
self.script()
out, err = capsys.readouterr()
assert excinfo.value.code == 1
@@ -1107,8 +1156,10 @@ class TestPkgdevCommit:
git_repo.add_all("cat/pkg-0")
repo.create_ebuild("cat/pkg-1", eapi="-1")
git_repo.add_all("cat/pkg-1", commit=False)
- with patch("sys.argv", self.args), pytest.raises(SystemExit) as excinfo, chdir(
- git_repo.path
+ with (
+ patch("sys.argv", self.args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(git_repo.path),
):
self.script()
assert excinfo.value.code == 1
diff --git a/tests/scripts/test_pkgdev_manifest.py b/tests/scripts/test_pkgdev_manifest.py
index e7cfcaf..d6bb34d 100644
--- a/tests/scripts/test_pkgdev_manifest.py
+++ b/tests/scripts/test_pkgdev_manifest.py
@@ -178,8 +178,10 @@ class TestPkgdevManifest:
def test_good_manifest(self, capsys, repo):
repo.create_ebuild("cat/pkg-0")
- with patch("sys.argv", self.args), pytest.raises(SystemExit) as excinfo, chdir(
- repo.location
+ with (
+ patch("sys.argv", self.args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(repo.location),
):
self.script()
assert excinfo.value.code == 0
@@ -189,8 +191,10 @@ class TestPkgdevManifest:
def test_bad_manifest(self, capsys, repo):
repo.create_ebuild("cat/pkg-0")
repo.create_ebuild("cat/pkg-1", eapi="-1")
- with patch("sys.argv", self.args), pytest.raises(SystemExit) as excinfo, chdir(
- repo.location
+ with (
+ patch("sys.argv", self.args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(repo.location),
):
self.script()
assert excinfo.value.code == 1
diff --git a/tests/scripts/test_pkgdev_mask.py b/tests/scripts/test_pkgdev_mask.py
index c7195fe..d723535 100644
--- a/tests/scripts/test_pkgdev_mask.py
+++ b/tests/scripts/test_pkgdev_mask.py
@@ -121,55 +121,76 @@ class TestPkgdevMask:
assert self.profile.masks == frozenset()
def test_nonexistent_editor(self, capsys):
- with os_environ("VISUAL", EDITOR="12345"), patch(
- "sys.argv", self.args + ["cat/pkg"]
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("VISUAL", EDITOR="12345"),
+ patch("sys.argv", self.args + ["cat/pkg"]),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
out, err = capsys.readouterr()
assert err.strip() == "pkgdev mask: error: nonexistent editor: '12345'"
def test_nonexistent_visual(self, capsys):
- with os_environ("EDITOR", VISUAL="12345"), patch(
- "sys.argv", self.args + ["cat/pkg"]
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("EDITOR", VISUAL="12345"),
+ patch("sys.argv", self.args + ["cat/pkg"]),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
out, err = capsys.readouterr()
assert err.strip() == "pkgdev mask: error: nonexistent editor: '12345'"
def test_failed_editor(self, capsys):
- with os_environ("VISUAL", EDITOR="sed -i 's///'"), patch(
- "sys.argv", self.args + ["cat/pkg"]
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("VISUAL", EDITOR="sed -i 's///'"),
+ patch("sys.argv", self.args + ["cat/pkg"]),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
out, err = capsys.readouterr()
assert err.strip() == "pkgdev mask: error: failed writing mask comment"
def test_empty_mask_comment(self, capsys):
- with os_environ("VISUAL", EDITOR="sed -i 's/#/#/'"), patch(
- "sys.argv", self.args + ["cat/pkg"]
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("VISUAL", EDITOR="sed -i 's/#/#/'"),
+ patch("sys.argv", self.args + ["cat/pkg"]),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
out, err = capsys.readouterr()
assert err.strip() == "pkgdev mask: error: empty mask comment"
def test_mask_cwd(self):
- with os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"), patch(
- "sys.argv", self.args
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path, "cat/pkg")):
+ with (
+ os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
+ patch("sys.argv", self.args),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path, "cat/pkg")),
+ ):
self.script()
assert self.profile.masks == frozenset([atom_cls("cat/pkg")])
def test_mask_target(self):
- with os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"), patch(
- "sys.argv", self.args + ["cat/pkg"]
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
+ patch("sys.argv", self.args + ["cat/pkg"]),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
assert self.profile.masks == frozenset([atom_cls("cat/pkg")])
def test_mask_ebuild_path(self):
- with os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"), patch(
- "sys.argv", self.args + ["cat/pkg/pkg-0.ebuild"]
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
+ patch("sys.argv", self.args + ["cat/pkg/pkg-0.ebuild"]),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
assert self.profile.masks == frozenset([atom_cls("=cat/pkg-0")])
@@ -184,9 +205,12 @@ class TestPkgdevMask:
)
)
- with os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"), patch(
- "sys.argv", self.args + ["=cat/pkg-0"]
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
+ patch("sys.argv", self.args + ["=cat/pkg-0"]),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
assert self.profile.masks == frozenset([atom_cls("cat/masked"), atom_cls("=cat/pkg-0")])
@@ -209,9 +233,12 @@ class TestPkgdevMask:
)
)
- with os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"), patch(
- "sys.argv", self.args + ["=cat/pkg-0"]
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
+ patch("sys.argv", self.args + ["=cat/pkg-0"]),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
_, err = capsys.readouterr()
assert "invalid mask entry header, lineno 9" in err
@@ -238,9 +265,12 @@ class TestPkgdevMask:
)
)
- with os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"), patch(
- "sys.argv", self.args + ["=cat/pkg-0"]
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
+ patch("sys.argv", self.args + ["=cat/pkg-0"]),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
_, err = capsys.readouterr()
assert "pkgdev mask: error: invalid author, lineno 5" in err
@@ -248,9 +278,12 @@ class TestPkgdevMask:
def test_last_rites(self):
for rflag in ("-r", "--rites"):
for args in ([rflag], [rflag, "14"]):
- with os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"), patch(
- "sys.argv", self.args + ["cat/pkg"] + args
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
+ patch("sys.argv", self.args + ["cat/pkg"] + args),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
days = 30 if len(args) == 1 else int(args[1])
@@ -271,12 +304,13 @@ class TestPkgdevMask:
def test_last_rites_with_email(self, tmp_path):
output_file = tmp_path / "mail.txt"
for rflag in ("-r", "--rites"):
- with os_environ(
- "VISUAL", EDITOR="sed -i '1s/$/mask comment/'", MAILER=f"> {output_file} echo"
- ), patch("sys.argv", self.args + ["cat/pkg", rflag, "--email"]), pytest.raises(
- SystemExit
- ), chdir(
- pjoin(self.repo.path)
+ with (
+ os_environ(
+ "VISUAL", EDITOR="sed -i '1s/$/mask comment/'", MAILER=f"> {output_file} echo"
+ ),
+ patch("sys.argv", self.args + ["cat/pkg", rflag, "--email"]),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
):
self.script()
out = output_file.read_text()
@@ -287,9 +321,12 @@ class TestPkgdevMask:
@pytest.mark.skipif(sys.platform == "darwin", reason="no xdg-email on mac os")
def test_last_email_bad_mailer(self, capsys):
for rflag in ("-r", "--rites"):
- with os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'", MAILER="false"), patch(
- "sys.argv", self.args + ["cat/pkg", rflag, "--email"]
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'", MAILER="false"),
+ patch("sys.argv", self.args + ["cat/pkg", rflag, "--email"]),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
_, err = capsys.readouterr()
assert err.strip() == "pkgdev mask: error: failed opening email composer"
@@ -304,9 +341,12 @@ class TestPkgdevMask:
args = []
for bug_num in bug_nums:
args += [bflag, bug_num]
- with os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"), patch(
- "sys.argv", self.args + ["cat/pkg"] + args
- ), pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
+ with (
+ os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
+ patch("sys.argv", self.args + ["cat/pkg"] + args),
+ pytest.raises(SystemExit),
+ chdir(pjoin(self.repo.path)),
+ ):
self.script()
assert self.masks_path.read_text() == textwrap.dedent(
diff --git a/tests/scripts/test_pkgdev_push.py b/tests/scripts/test_pkgdev_push.py
index fb4faa3..a84c175 100644
--- a/tests/scripts/test_pkgdev_push.py
+++ b/tests/scripts/test_pkgdev_push.py
@@ -90,8 +90,10 @@ class TestPkgdevPush:
self.child_repo.create_ebuild("cat/pkg-1")
self.child_git_repo.add_all("cat/pkg-1")
- with patch("sys.argv", self.args), pytest.raises(SystemExit) as excinfo, chdir(
- self.child_git_repo.path
+ with (
+ patch("sys.argv", self.args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(self.child_git_repo.path),
):
self.script()
assert excinfo.value.code == 0
@@ -101,8 +103,10 @@ class TestPkgdevPush:
self.child_git_repo.add_all("cat/pkg-1")
# failed scans don't push commits
- with patch("sys.argv", self.args), pytest.raises(SystemExit) as excinfo, chdir(
- self.child_git_repo.path
+ with (
+ patch("sys.argv", self.args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(self.child_git_repo.path),
):
self.script()
assert excinfo.value.code == 1
@@ -119,9 +123,12 @@ class TestPkgdevPush:
)
# but failures can be ignored to push anyway
- with patch("sys.argv", self.args + ["--ask"]), patch(
- "sys.stdin", StringIO("y\n")
- ), pytest.raises(SystemExit) as excinfo, chdir(self.child_git_repo.path):
+ with (
+ patch("sys.argv", self.args + ["--ask"]),
+ patch("sys.stdin", StringIO("y\n")),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(self.child_git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 0
@@ -133,17 +140,22 @@ class TestPkgdevPush:
self.child_git_repo.add_all("cat/pkg-1")
# scans with warnings ask for confirmation before pushing with "--ask"
- with patch("sys.argv", self.args + ["--ask"]), patch(
- "sys.stdin", StringIO("n\n")
- ), pytest.raises(SystemExit) as excinfo, chdir(self.child_git_repo.path):
+ with (
+ patch("sys.argv", self.args + ["--ask"]),
+ patch("sys.stdin", StringIO("n\n")),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(self.child_git_repo.path),
+ ):
self.script()
assert excinfo.value.code == 1
out, err = capsys.readouterr()
assert "EmptyFile" in out
# but without "--ask" it still pushes
- with patch("sys.argv", self.args), pytest.raises(SystemExit) as excinfo, chdir(
- self.child_git_repo.path
+ with (
+ patch("sys.argv", self.args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(self.child_git_repo.path),
):
self.script()
assert excinfo.value.code == 0
diff --git a/tests/scripts/test_pkgdev_showkw.py b/tests/scripts/test_pkgdev_showkw.py
index c30a4f0..8dadb5d 100644
--- a/tests/scripts/test_pkgdev_showkw.py
+++ b/tests/scripts/test_pkgdev_showkw.py
@@ -86,9 +86,10 @@ class TestPkgdevShowkw:
return repo
def _run_and_parse(self, capsys, *args):
- with patch("sys.argv", [*self.base_args, "--format", "presto", *args]), pytest.raises(
- SystemExit
- ) as excinfo:
+ with (
+ patch("sys.argv", [*self.base_args, "--format", "presto", *args]),
+ pytest.raises(SystemExit) as excinfo,
+ ):
self.script()
assert excinfo.value.code is None
out, err = capsys.readouterr()
@@ -103,9 +104,10 @@ class TestPkgdevShowkw:
def test_match(self, capsys, make_repo):
repo = self._create_repo(make_repo)
repo.create_ebuild("foo/bar-0")
- with patch("sys.argv", [*self.base_args, "-r", repo.location, "foo/bar"]), pytest.raises(
- SystemExit
- ) as excinfo:
+ with (
+ patch("sys.argv", [*self.base_args, "-r", repo.location, "foo/bar"]),
+ pytest.raises(SystemExit) as excinfo,
+ ):
self.script()
assert excinfo.value.code is None
out, err = capsys.readouterr()
@@ -115,9 +117,10 @@ class TestPkgdevShowkw:
def test_match_short_name(self, capsys, make_repo):
repo = self._create_repo(make_repo)
repo.create_ebuild("foo/bar-0")
- with patch("sys.argv", [*self.base_args, "-r", repo.location, "bar"]), pytest.raises(
- SystemExit
- ) as excinfo:
+ with (
+ patch("sys.argv", [*self.base_args, "-r", repo.location, "bar"]),
+ pytest.raises(SystemExit) as excinfo,
+ ):
self.script()
assert excinfo.value.code is None
out, err = capsys.readouterr()
@@ -127,9 +130,11 @@ class TestPkgdevShowkw:
def test_match_cwd_repo(self, capsys, make_repo):
repo = self._create_repo(make_repo)
repo.create_ebuild("foo/bar-0")
- with patch("sys.argv", [*self.base_args, "foo/bar"]), pytest.raises(
- SystemExit
- ) as excinfo, chdir(repo.location):
+ with (
+ patch("sys.argv", [*self.base_args, "foo/bar"]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(repo.location),
+ ):
self.script()
assert excinfo.value.code is None
out, err = capsys.readouterr()
@@ -139,8 +144,10 @@ class TestPkgdevShowkw:
def test_match_cwd_pkg(self, capsys, make_repo):
repo = self._create_repo(make_repo)
repo.create_ebuild("foo/bar-0")
- with patch("sys.argv", self.base_args), pytest.raises(SystemExit) as excinfo, chdir(
- repo.location + "/foo/bar"
+ with (
+ patch("sys.argv", self.base_args),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(repo.location + "/foo/bar"),
):
self.script()
assert excinfo.value.code is None
@@ -149,9 +156,10 @@ class TestPkgdevShowkw:
def test_no_matches(self, capsys, make_repo):
repo = self._create_repo(make_repo)
- with patch("sys.argv", [*self.base_args, "-r", repo.location, "foo/bar"]), pytest.raises(
- SystemExit
- ) as excinfo:
+ with (
+ patch("sys.argv", [*self.base_args, "-r", repo.location, "foo/bar"]),
+ pytest.raises(SystemExit) as excinfo,
+ ):
self.script()
assert excinfo.value.code == 1
out, err = capsys.readouterr()
@@ -212,9 +220,10 @@ class TestPkgdevShowkw:
repo = self._create_repo(make_repo)
repo.create_ebuild("foo/bar-0", keywords=("amd64", "~ia64", "~mips", "~x86"))
repo.create_ebuild("foo/bar-1", keywords=("~amd64", "~ia64", "~mips", "x86"))
- with patch(
- "sys.argv", [*self.base_args, "-r", repo.location, "foo/bar", "--collapse", arg]
- ), pytest.raises(SystemExit) as excinfo:
+ with (
+ patch("sys.argv", [*self.base_args, "-r", repo.location, "foo/bar", "--collapse", arg]),
+ pytest.raises(SystemExit) as excinfo,
+ ):
self.script()
out, err = capsys.readouterr()
assert excinfo.value.code is None
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/
@ 2023-12-29 12:32 Arthur Zamarin
0 siblings, 0 replies; 5+ messages in thread
From: Arthur Zamarin @ 2023-12-29 12:32 UTC (permalink / raw
To: gentoo-commits
commit: 243c25df49582acea3e136e3e871fa7daa2b940b
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 29 12:31:19 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 29 12:31:19 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=243c25df
test_pkgdev_manifest: skip broken tests [wip]
Were broken by [1]. Understanding what and why happened is not trivial.
Many manual tests I've performed show that `pkgdev manifest` still works
as expected. I'm not sure if the tests are broken or the code is broken.
[1] https://github.com/pkgcore/pkgcore/commit/bb7b8ec465060dfc754e9115c6e8a03e040272fd
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
tests/scripts/test_pkgdev_manifest.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/scripts/test_pkgdev_manifest.py b/tests/scripts/test_pkgdev_manifest.py
index 0645be0..e7cfcaf 100644
--- a/tests/scripts/test_pkgdev_manifest.py
+++ b/tests/scripts/test_pkgdev_manifest.py
@@ -16,6 +16,7 @@ class TestPkgdevManifestParseArgs:
out, err = capsys.readouterr()
assert err.strip() == "pkgdev manifest: error: not in ebuild repo"
+ @pytest.mark.skip
def test_repo_cwd(self, repo, capsys, tool):
repo.create_ebuild("cat/pkg-0")
with chdir(repo.location):
@@ -31,6 +32,7 @@ class TestPkgdevManifestParseArgs:
matches = [x.cpvstr for x in repo.itermatch(options.restriction)]
assert matches == ["cat/pkg-0"]
+ @pytest.mark.skip
def test_repo_relative_category(self, repo, capsys, tool):
repo.create_ebuild("cat/pkg-0")
repo.create_ebuild("cat/newpkg-0")
@@ -58,6 +60,7 @@ class TestPkgdevManifestParseArgs:
== f"pkgdev manifest: error: {repo.repo_id!r} repo doesn't contain: {str(ebuild)!r}"
)
+ @pytest.mark.skip
def test_dir_target(self, repo, capsys, tool):
repo.create_ebuild("cat/pkg-0")
with chdir(repo.location):
@@ -128,6 +131,7 @@ class TestPkgdevManifestParseArgs:
git_repo.remove(ebuild_path, commit=False)
assert manifest_matches() == set()
+ @pytest.mark.skip
def test_ignore_fetch_restricted(self, repo, tool):
def manifest_matches() -> List[str]:
with chdir(repo.location):
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/
@ 2023-05-28 19:41 Arthur Zamarin
0 siblings, 0 replies; 5+ messages in thread
From: Arthur Zamarin @ 2023-05-28 19:41 UTC (permalink / raw
To: gentoo-commits
commit: 18132b04dfc68a821df6b876fcd66a79bd2f2980
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun May 28 19:40:28 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun May 28 19:41:36 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=18132b04
tests/bugs: fix tests after addition of blocks_bug
Fixes: f5b955018af5715bdd72ce6b094bf901be2d8ced
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
tests/scripts/test_pkgdev_bugs.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/scripts/test_pkgdev_bugs.py b/tests/scripts/test_pkgdev_bugs.py
index 708ff39..e020ffd 100644
--- a/tests/scripts/test_pkgdev_bugs.py
+++ b/tests/scripts/test_pkgdev_bugs.py
@@ -68,7 +68,7 @@ class TestBugFiling:
session = BugsSession()
pkg = max(repo.itermatch(atom("=cat/u-0")))
with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session):
- bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset())
+ bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), ())
assert len(session.calls) == 1
call = session.calls[0]
assert call["Bugzilla_api_key"] == "API"
@@ -83,7 +83,7 @@ class TestBugFiling:
session = BugsSession()
pkg = max(repo.itermatch(atom("=cat/z-0")))
with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session):
- bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset())
+ bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), ())
assert len(session.calls) == 1
call = session.calls[0]
assert call["assigned_to"] == "maintainer-needed@gentoo.org"
@@ -99,7 +99,7 @@ class TestBugFiling:
node = bugs.GraphNode(((pkgX, {"*"}), (pkgY, {"*"}), (pkgZ, {"*"})))
node.edges.add(dep)
with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session):
- node.file_bug("API", frozenset())
+ node.file_bug("API", frozenset(), ())
assert len(session.calls) == 1
call = session.calls[0]
assert call["summary"] == "cat/x-0, cat/y-0, cat/z-0: stablereq"
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/
@ 2022-11-19 17:22 Arthur Zamarin
0 siblings, 0 replies; 5+ messages in thread
From: Arthur Zamarin @ 2022-11-19 17:22 UTC (permalink / raw
To: gentoo-commits
commit: f9c6971a98ed76679e97e08ec25c4ab560921d21
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 19 17:21:57 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 19 17:21:57 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=f9c6971a
tests/scripts/test_pkgdev_showkw.py: fix NOCOLOR test
Fix the test for systems which predefine NOCOLOR, like in case of ebuild
test environment (by epytest).
Follows: 9714e4785e1ffc56a08f042011b5a966c7520a1f
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
tests/scripts/test_pkgdev_showkw.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/scripts/test_pkgdev_showkw.py b/tests/scripts/test_pkgdev_showkw.py
index fe06be9..c611484 100644
--- a/tests/scripts/test_pkgdev_showkw.py
+++ b/tests/scripts/test_pkgdev_showkw.py
@@ -50,7 +50,8 @@ class TestPkgdevShowkwParseArgs:
'--config', str(config_file), *args])
return options
- assert parse().color is True
+ with os_environ('NOCOLOR'):
+ assert parse().color is True
with os_environ(NOCOLOR='1'):
# NOCOLOR overrides config file
assert parse().color is False
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-20 15:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-20 15:37 [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/ Arthur Zamarin
-- strict thread matches above, loose matches on Subject: below --
2024-01-26 20:22 Arthur Zamarin
2023-12-29 12:32 Arthur Zamarin
2023-05-28 19:41 Arthur Zamarin
2022-11-19 17:22 Arthur Zamarin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox