aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-10-27 11:31:13 -0700
committerCody Logan <cody@lokken.dev>2023-10-27 11:31:13 -0700
commit648496c1492c3e54f8b8965d9511d652d18ee8cd (patch)
treec6006343b17a8945e963da4939f25bec53f3f2f8 /tests
parent9660c5bb498666bf6385c27e6e611e3512dc40d7 (diff)
downloadwikiget-648496c1492c3e54f8b8965d9511d652d18ee8cd.tar.gz
wikiget-648496c1492c3e54f8b8965d9511d652d18ee8cd.zip
Refactor args construction in tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test_client.py8
-rw-r--r--tests/test_dl.py4
2 files changed, 4 insertions, 8 deletions
diff --git a/tests/test_client.py b/tests/test_client.py
index 448ab67..41ce948 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -27,17 +27,15 @@ from wikiget.wikiget import construct_parser
# TODO: don't hit the actual API when doing tests
@pytest.mark.skip(reason="skip tests that query a live API")
class TestQueryApi:
- parser = construct_parser()
+ args = construct_parser().parse_args(["File:Example.jpg"])
def test_connect_to_site(self, caplog: pytest.LogCaptureFixture) -> None:
caplog.set_level(logging.DEBUG)
- args = self.parser.parse_args(["File:Example.jpg"])
- _ = connect_to_site("commons.wikimedia.org", args)
+ _ = connect_to_site("commons.wikimedia.org", self.args)
assert "Connecting to commons.wikimedia.org" in caplog.text
def test_query_api(self, caplog: pytest.LogCaptureFixture) -> None:
caplog.set_level(logging.DEBUG)
- args = self.parser.parse_args(["File:Example.jpg"])
- site = connect_to_site("commons.wikimedia.org", args)
+ site = connect_to_site("commons.wikimedia.org", self.args)
_ = query_api("Example.jpg", site)
assert USER_AGENT in caplog.text
diff --git a/tests/test_dl.py b/tests/test_dl.py
index c0dcf0c..5477b5f 100644
--- a/tests/test_dl.py
+++ b/tests/test_dl.py
@@ -24,9 +24,7 @@ from wikiget.wikiget import construct_parser
# TODO: don't hit the actual API when doing tests
@pytest.mark.skip(reason="skip tests that query a live API")
class TestPrepDownload:
- parser = construct_parser()
-
def test_prep_download(self) -> None:
- args = self.parser.parse_args(["File:Example.jpg"])
+ args = construct_parser().parser.parse_args(["File:Example.jpg"])
file = prep_download(args.FILE, args)
assert file is not None