aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_parse.py21
-rw-r--r--tests/test_validations.py13
2 files changed, 18 insertions, 16 deletions
diff --git a/tests/test_parse.py b/tests/test_parse.py
index d289d1d..e3bef2d 100644
--- a/tests/test_parse.py
+++ b/tests/test_parse.py
@@ -15,10 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with Wikiget. If not, see <https://www.gnu.org/licenses/>.
+from __future__ import annotations
+
import io
import logging
from pathlib import Path
-from typing import Dict
import pytest
@@ -93,7 +94,7 @@ class TestGetDest:
class TestReadBatchFile:
@pytest.fixture()
- def dl_dict(self, tmp_path: Path) -> Dict[int, str]:
+ def dl_dict(self, tmp_path: Path) -> dict[int, str]:
"""
Create and process a test batch file with three lines, returning a dictionary.
"""
@@ -114,14 +115,14 @@ class TestReadBatchFile:
_ = read_batch_file(str(tmp_file))
assert f"Using file '{tmp_file}' for batch download" in caplog.text
- def test_batch_file_length(self, dl_dict: Dict[int, str]) -> None:
+ def test_batch_file_length(self, dl_dict: dict[int, str]) -> None:
"""
The processed batch dict should have the same number of items as lines in the
batch file.
"""
assert len(dl_dict) == 3
- def test_batch_file_contents(self, dl_dict: Dict[int, str]) -> None:
+ def test_batch_file_contents(self, dl_dict: dict[int, str]) -> None:
"""
The processed batch dict should have the correct line numbers and filenames as
keys and values, respectively.
@@ -130,7 +131,7 @@ class TestReadBatchFile:
assert dl_dict == expected_list
@pytest.fixture()
- def dl_dict_stdin(self, monkeypatch: pytest.MonkeyPatch) -> Dict[int, str]:
+ def dl_dict_stdin(self, monkeypatch: pytest.MonkeyPatch) -> dict[int, str]:
"""
Pass three lines of filenames from stdin to read_batch_file and return a dict.
"""
@@ -150,14 +151,14 @@ class TestReadBatchFile:
_ = read_batch_file("-")
assert "Using stdin for batch download" in caplog.text
- def test_batch_stdin_length(self, dl_dict_stdin: Dict[int, str]) -> None:
+ def test_batch_stdin_length(self, dl_dict_stdin: dict[int, str]) -> None:
"""
The processed batch dict should have the same number of items as lines in the
input.
"""
assert len(dl_dict_stdin) == 3
- def test_batch_stdin_contents(self, dl_dict_stdin: Dict[int, str]) -> None:
+ def test_batch_stdin_contents(self, dl_dict_stdin: dict[int, str]) -> None:
"""
The processed batch dict should have the correct line numbers and filenames as
keys and values, respectively.
@@ -166,7 +167,7 @@ class TestReadBatchFile:
assert dl_dict_stdin == expected_list
@pytest.fixture()
- def dl_dict_with_comment(self, tmp_path: Path) -> Dict[int, str]:
+ def dl_dict_with_comment(self, tmp_path: Path) -> dict[int, str]:
"""
Create and process a test batch file with four lines, one of which is
commented out and another of which is blank, and return a dictionary.
@@ -176,7 +177,7 @@ class TestReadBatchFile:
return read_batch_file(str(tmp_file))
def test_batch_file_with_comment_length(
- self, dl_dict_with_comment: Dict[int, str]
+ self, dl_dict_with_comment: dict[int, str]
) -> None:
"""
The processed batch dict should contain the same number of items as uncommented
@@ -185,7 +186,7 @@ class TestReadBatchFile:
assert len(dl_dict_with_comment) == 2
def test_batch_file_with_comment_contents(
- self, dl_dict_with_comment: Dict[int, str]
+ self, dl_dict_with_comment: dict[int, str]
) -> None:
"""
The processed batch dict should have the correct line numbers and filenames as
diff --git a/tests/test_validations.py b/tests/test_validations.py
index a1c57b5..a8fbf1b 100644
--- a/tests/test_validations.py
+++ b/tests/test_validations.py
@@ -15,9 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with Wikiget. If not, see <https://www.gnu.org/licenses/>.
+from __future__ import annotations
+
from pathlib import Path
from re import Match
-from typing import Optional
import pytest
@@ -33,7 +34,7 @@ class TestSiteInput:
"en.wikimpedia.org",
],
)
- def invalid_input(self, request: pytest.FixtureRequest) -> Optional[Match]:
+ def invalid_input(self, request: pytest.FixtureRequest) -> Match | None:
return valid_site(request.param)
@pytest.fixture(
@@ -44,7 +45,7 @@ class TestSiteInput:
"meta.wikimedia.org",
],
)
- def valid_input(self, request: pytest.FixtureRequest) -> Optional[Match]:
+ def valid_input(self, request: pytest.FixtureRequest) -> Match | None:
return valid_site(request.param)
def test_invalid_site_input(self, invalid_input: None) -> None:
@@ -58,7 +59,7 @@ class TestSiteInput:
class TestFileRegex:
@pytest.fixture()
- def file_match(self) -> Optional[Match]:
+ def file_match(self) -> Match | None:
"""
File regex should return a match object with match groups corresponding
to the file prefix and name.
@@ -87,7 +88,7 @@ class TestFileInput:
"Fil:Example.jpg",
],
)
- def invalid_input(self, request: pytest.FixtureRequest) -> Optional[Match]:
+ def invalid_input(self, request: pytest.FixtureRequest) -> Match | None:
return valid_file(request.param)
@pytest.fixture(
@@ -100,7 +101,7 @@ class TestFileInput:
"File:A (1).jpeg",
],
)
- def valid_input(self, request: pytest.FixtureRequest) -> Optional[Match]:
+ def valid_input(self, request: pytest.FixtureRequest) -> Match | None:
return valid_file(request.param)
def test_invalid_file_input(self, invalid_input: None) -> None: