aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-12-01 15:42:17 -0800
committerCody Logan <cody@lokken.dev>2023-12-01 15:42:17 -0800
commit514023f4c76cd140992a4ca6af769db0843ffce5 (patch)
treeb5b18931091547016dac252e267be0660619ec38 /tests
parent318d9ad1a4679832b380c77ab1a0a86684f686f2 (diff)
downloadwikiget-docstrings.tar.gz
wikiget-docstrings.zip
Convert additional docstrings to Google-styledocstrings
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py46
-rw-r--r--tests/test_dl.py4
-rw-r--r--tests/test_parse.py35
-rw-r--r--tests/test_validations.py44
4 files changed, 71 insertions, 58 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 128b581..f8d2c7e 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -48,10 +48,9 @@ def _chdir_to_tmp_dir(
) -> None:
"""Change to the base temporary directory before running tests.
- :param tmp_path_factory: temporary path generator
- :type tmp_path_factory: pytest.TempPathFactory
- :param tmp_path_factory: Pytest monkeypatch helper
- :type tmp_path_factory: pytest.MonkeyPatch
+ Args:
+ tmp_path_factory (pytest.TempPathFactor): temporary path generator
+ monkeypatch (pytest.MonkeyPatch): Pytest monkeypatch helper
"""
monkeypatch.chdir(tmp_path_factory.getbasetemp())
@@ -60,10 +59,11 @@ def _chdir_to_tmp_dir(
def batch_file(tmp_path_factory: pytest.TempPathFactory) -> Path:
"""Create a temporary batch file for testing.
- :param tmp_path_factory: temporary path generator
- :type tmp_path_factory: pytest.TempPathFactory
- :return: test batch file
- :rtype: pathlib.Path
+ Args:
+ tmp_path_factory (pytest.TempPathFactor): temporary path generator
+
+ Returns:
+ pathlib.Path: test batch file
"""
tmp_file = tmp_path_factory.getbasetemp() / "batch.txt"
tmp_file.write_text("File:Foo.jpg\nFile:Bar.jpg\nFile:Baz.jpg\n")
@@ -74,10 +74,11 @@ def batch_file(tmp_path_factory: pytest.TempPathFactory) -> Path:
def batch_file_with_comment(tmp_path_factory: pytest.TempPathFactory) -> Path:
"""Create a temporary batch file with comments for testing.
- :param tmp_path_factory: temporary path generator
- :type tmp_path_factory: pytest.TempPathFactory
- :return: test batch file
- :rtype: pathlib.Path
+ Args:
+ tmp_path_factory (pytest.TempPathFactor): temporary path generator
+
+ Returns:
+ pathlib.Path: test batch file
"""
tmp_file = tmp_path_factory.getbasetemp() / "batch_with_comment.txt"
tmp_file.write_text("File:Foo.jpg\n\n#File:Bar.jpg\nFile:Baz.jpg\n")
@@ -88,10 +89,11 @@ def batch_file_with_comment(tmp_path_factory: pytest.TempPathFactory) -> Path:
def test_file(tmp_path_factory: pytest.TempPathFactory) -> Path:
"""Create a fake downloaded file with known contents.
- :param tmp_path_factory: temporary path generator
- :type tmp_path_factory: pytest.TempPathFactory
- :return: test file
- :rtype: pathlib.Path
+ Args:
+ tmp_path_factory (pytest.TempPathFactor): temporary path generator
+
+ Returns:
+ pathlib.Path: test file
"""
tmp_file = tmp_path_factory.getbasetemp() / "Testfile.jpg"
tmp_file.write_bytes(TEST_FILE_BYTES)
@@ -105,8 +107,8 @@ def file_with_name() -> File:
A File object created with only a name should set its destination property to
the same value and its site property to the program's default site.
- :return: File object created using a filename
- :rtype: wikiget.file.File
+ Returns:
+ wikiget.file.File: File object created using a filename
"""
return File("foobar.jpg")
@@ -115,8 +117,8 @@ def file_with_name() -> File:
def file_with_name_and_dest() -> File:
"""Create a test File with a name and destination.
- :return: File object created with name and dest
- :rtype: wikiget.file.File
+ Returns:
+ wikiget.file.File: File object created with name and dest
"""
return File(name="foobar.jpg", dest="bazqux.jpg")
@@ -125,8 +127,8 @@ def file_with_name_and_dest() -> File:
def _mock_get(requests_mock: rm.Mocker) -> None:
"""Fake the download request for the true URL of File:Example.jpg.
- :param requests_mock: a requests_mock Mocker object
- :type requests_mock: requests_mock.Mocker
+ Args:
+ requests_mock (requests_mock.Mocker): a requests_mock Mocker object
"""
requests_mock.get(
"https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg",
diff --git a/tests/test_dl.py b/tests/test_dl.py
index 63408eb..ee778d7 100644
--- a/tests/test_dl.py
+++ b/tests/test_dl.py
@@ -333,8 +333,8 @@ class TestDownload:
def mock_file(self) -> File:
"""Create a mock File object to test against.
- :return: mock File object
- :rtype: File
+ Returns:
+ wikiget.file.File: mock File object
"""
file = File(name="Example.jpg")
file.image = Mock()
diff --git a/tests/test_parse.py b/tests/test_parse.py
index bec2113..58e5c34 100644
--- a/tests/test_parse.py
+++ b/tests/test_parse.py
@@ -45,8 +45,8 @@ class TestGetDest:
When only the filename is given as an argument, the dest attribute will be set
to the same value as the filename and the default site will be used.
- :return: a File object created using a filename
- :rtype: wikiget.file.File
+ Returns:
+ wikiget.file.File: a File object created using a filename
"""
args = parse_args(["File:Example.jpg"])
return get_dest(args.FILE, args)
@@ -76,8 +76,8 @@ class TestGetDest:
When a URL is passed to get_dest, it will create a File object with the
filename and site parsed from the URL.
- :return: a File object created using a URL
- :rtype: wikiget.file.File
+ Returns:
+ wikiget.file.File: a File object created using a URL
"""
args = parse_args(["https://en.wikipedia.org/wiki/File:Example.jpg"])
return get_dest(args.FILE, args)
@@ -129,10 +129,11 @@ class TestReadBatchFile:
def dl_dict(self, batch_file: Path) -> dict[int, str]:
"""Create and process a test batch file with three lines.
- :param batch_file: test batch file
- :type batch_file: pathlib.Path
- :return: dictionary representation of the input file
- :rtype: dict[int, str]
+ Args:
+ batch_file (pathlib.Path): test batch file
+
+ Returns:
+ dict[int, str]: dictionary representation of the input file
"""
return read_batch_file(str(batch_file))
@@ -165,10 +166,11 @@ class TestReadBatchFile:
def dl_dict_stdin(self, monkeypatch: pytest.MonkeyPatch) -> dict[int, str]:
"""Pass three lines of filenames from stdin to read_batch_file to create a dict.
- :param monkeypatch: Pytest monkeypatch helper
- :type monkeypatch: pytest.MonkeyPatch
- :return: dictionary representation of the input
- :rtype: dict[int, str]
+ Args:
+ monkeypatch (pytest.MonkeyPatch): Pytest monkeypatch helper
+
+ Returns:
+ dict[int, str]: dictionary representation of the input
"""
monkeypatch.setattr(
"sys.stdin", io.StringIO("File:Foo.jpg\nFile:Bar.jpg\nFile:Baz.jpg\n")
@@ -206,10 +208,11 @@ class TestReadBatchFile:
In addition to filenames, one line is commented out and another line is blank.
- :param batch_file_with_comment: test batch file
- :type batch_file_with_comment: pathlib.Path
- :return: dictionary representation of the input file
- :rtype: dict[int, str]
+ Args:
+ batch_file_with_comment (pathlib.Path): test batch file
+
+ Returns:
+ dict[int, str]: dictionary representation of the input file
"""
return read_batch_file(str(batch_file_with_comment))
diff --git a/tests/test_validations.py b/tests/test_validations.py
index 780303a..b9d4fb9 100644
--- a/tests/test_validations.py
+++ b/tests/test_validations.py
@@ -44,10 +44,12 @@ class TestSiteInput:
def invalid_input(self, request: pytest.FixtureRequest) -> re.Match | None:
"""Return the results of checking various invalid site names.
- :param request: Pytest request object containing parameter values
- :type request: pytest.FixtureRequest
- :return: a Match object for the site or None if there was no match
- :rtype: re.Match
+ Args:
+ request (pytest.FixtureRequest): Pytest request object containing parameter
+ values
+
+ Returns:
+ re.Match: a Match object for the site or None if there was no match
"""
return valid_site(request.param)
@@ -62,10 +64,12 @@ class TestSiteInput:
def valid_input(self, request: pytest.FixtureRequest) -> re.Match | None:
"""Return the results of checking various valid site names.
- :param request: Pytest request object containing parameter values
- :type request: pytest.FixtureRequest
- :return: a Match object for the site or None if there was no match
- :rtype: re.Match
+ Args:
+ request (pytest.FixtureRequest): Pytest request object containing parameter
+ values
+
+ Returns:
+ re.Match: a Match object for the site or None if there was no match
"""
return valid_site(request.param)
@@ -88,8 +92,8 @@ class TestFileRegex:
The match object returned will have match groups corresponding to the file
prefix and name.
- :return: a Match object for the filename or None if there was no match
- :rtype: re.Match
+ Returns:
+ re.Match: a Match object for the filename or None if there was no match
"""
return valid_file("File:Example.jpg")
@@ -124,10 +128,12 @@ class TestFileInput:
def invalid_input(self, request: pytest.FixtureRequest) -> re.Match | None:
"""Return the results of checking various invalid filenames.
- :param request: Pytest request object containing parameter values
- :type request: pytest.FixtureRequest
- :return: a Match object for the filename or None if there was no match
- :rtype: re.Match
+ Args:
+ request (pytest.FixtureRequest): Pytest request object containing parameter
+ values
+
+ Returns:
+ re.Match: a Match object for the filename or None if there was no match
"""
return valid_file(request.param)
@@ -144,10 +150,12 @@ class TestFileInput:
def valid_input(self, request: pytest.FixtureRequest) -> re.Match | None:
"""Return the results of checking various valid filenames.
- :param request: Pytest request object containing parameter values
- :type request: pytest.FixtureRequest
- :return: a Match object for the filename or None if there was no match
- :rtype: re.Match
+ Args:
+ request (pytest.FixtureRequest): Pytest request object containing parameter
+ values
+
+ Returns:
+ re.Match: a Match object for the filename or None if there was no match
"""
return valid_file(request.param)