From 206f0fe0b97610fc371ad0acdd5146ac12eacfe7 Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Mon, 9 Oct 2023 13:50:30 -0700 Subject: Style cleanup --- pyproject.toml | 2 +- src/wikiget/wikiget.py | 2 +- tests/test_dl.py | 27 ++++++++++++++------------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3364ec0..8dc16ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -188,5 +188,5 @@ exclude_lines = [ ] [[tool.mypy.overrides]] -module = ["mwclient"] +module = ["mwclient", "pytest"] ignore_missing_imports = true diff --git a/src/wikiget/wikiget.py b/src/wikiget/wikiget.py index 51c870a..8c067e0 100644 --- a/src/wikiget/wikiget.py +++ b/src/wikiget/wikiget.py @@ -104,7 +104,7 @@ def construct_parser(): "-j", "--threads", default=1, - help="Number of parallel downloads to attempt in batch mode", + help="number of parallel downloads to attempt in batch mode", type=int, ) diff --git a/tests/test_dl.py b/tests/test_dl.py index 396041d..abf8763 100644 --- a/tests/test_dl.py +++ b/tests/test_dl.py @@ -15,13 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Wikiget. If not, see . -# import logging import pytest -# from wikiget import USER_AGENT -from wikiget.wikiget import construct_parser -# from wikiget.dl import get_dest, query_api, prep_download from wikiget.dl import get_dest +from wikiget.wikiget import construct_parser class TestGetDest: @@ -35,9 +32,11 @@ class TestGetDest: assert site_name == "commons.wikimedia.org" def test_get_dest_with_url(self): - args = self.parser.parse_args([ - "https://en.wikipedia.org/wiki/File:Example.jpg", - ]) + args = self.parser.parse_args( + [ + "https://en.wikipedia.org/wiki/File:Example.jpg", + ] + ) filename, dest, site_name = get_dest(args.FILE, args) assert filename == "Example.jpg" assert dest == "Example.jpg" @@ -48,12 +47,14 @@ class TestGetDest: with pytest.raises(SystemExit): filename, dest, site_name = get_dest(args.FILE, args) - def test_get_dest_with_different_site(self, caplog): - args = self.parser.parse_args([ - "https://commons.wikimedia.org/wiki/File:Example.jpg", - "--site", - "commons.wikimedia.org", - ]) + def test_get_dest_with_different_site(self, caplog: pytest.LogCaptureFixture): + args = self.parser.parse_args( + [ + "https://commons.wikimedia.org/wiki/File:Example.jpg", + "--site", + "commons.wikimedia.org", + ] + ) filename, dest, site_name = get_dest(args.FILE, args) assert "target is a URL, ignoring site specified with --site" in caplog.text -- cgit v1.2.3