diff options
| author | Cody Logan <cody@lokken.dev> | 2023-11-15 10:02:48 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-15 10:02:48 -0800 |
| commit | 55a5311ee4da639a65bd60622315f3fff6936c9a (patch) | |
| tree | 285f960d4a7afe9d27ecca51e86e7f00fb914d22 /tests/test_parse.py | |
| parent | 96316c8be7bc21617ec5333f87864a0f002ebaa4 (diff) | |
| parent | ba782d54aa70a1faf6bf6cdcaeb446f7b4c503db (diff) | |
| download | wikiget-55a5311ee4da639a65bd60622315f3fff6936c9a.tar.gz wikiget-55a5311ee4da639a65bd60622315f3fff6936c9a.zip | |
Merge pull request #13 from clpo13/testing-tmp-folder
Change to temp directory when running tests
Diffstat (limited to 'tests/test_parse.py')
| -rw-r--r-- | tests/test_parse.py | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/tests/test_parse.py b/tests/test_parse.py index fbbd1b7..fb824d4 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -46,7 +46,7 @@ class TestGetDest: to the same value as the filename and the default site will be used. :return: a File object created using a filename - :rtype: File + :rtype: wikiget.file.File """ args = parse_args(["File:Example.jpg"]) return get_dest(args.FILE, args) @@ -77,7 +77,7 @@ class TestGetDest: filename and site parsed from the URL. :return: a File object created using a URL - :rtype: File + :rtype: wikiget.file.File """ args = parse_args(["https://en.wikipedia.org/wiki/File:Example.jpg"]) return get_dest(args.FILE, args) @@ -126,20 +126,18 @@ class TestReadBatchFile: """Define tests related to wikiget.parse.read_batch_file.""" @pytest.fixture() - def dl_dict(self, tmp_path: Path) -> dict[int, str]: + def dl_dict(self, batch_file: Path) -> dict[int, str]: """Create and process a test batch file with three lines. - :param tmp_path: temporary path object - :type tmp_path: Path + :param batch_file: test batch file + :type batch_file: pathlib.Path :return: dictionary representation of the input file :rtype: dict[int, str] """ - tmp_file = tmp_path / "batch.txt" - tmp_file.write_text("File:Foo.jpg\nFile:Bar.jpg\nFile:Baz.jpg\n") - return read_batch_file(str(tmp_file)) + return read_batch_file(str(batch_file)) def test_batch_file_log( - self, caplog: pytest.LogCaptureFixture, tmp_path: Path + self, caplog: pytest.LogCaptureFixture, batch_file: Path ) -> None: """Test that reading a batch file creates an info log message. @@ -147,10 +145,8 @@ class TestReadBatchFile: of the batch file. """ caplog.set_level(logging.INFO) - tmp_file = tmp_path / "batch.txt" - tmp_file.write_text("File:Foo.jpg\n") - _ = read_batch_file(str(tmp_file)) - assert f"Using file '{tmp_file}' for batch download" in caplog.text + _ = read_batch_file(str(batch_file)) + assert f"Using file '{batch_file}' for batch download" in caplog.text def test_batch_file_length(self, dl_dict: dict[int, str]) -> None: """Test that the batch dict has the same number of lines as the batch file.""" @@ -205,19 +201,17 @@ 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, batch_file_with_comment: Path) -> dict[int, str]: """Create and process a test batch file with four lines. In addition to filenames, one line is commented out and another line is blank. - :param tmp_path: temporary path object - :type tmp_path: Path + :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] """ - tmp_file = tmp_path / "batch.txt" - tmp_file.write_text("File:Foo.jpg\n\n#File:Bar.jpg\nFile:Baz.jpg\n") - return read_batch_file(str(tmp_file)) + return read_batch_file(str(batch_file_with_comment)) def test_batch_file_with_comment_length( self, dl_dict_with_comment: dict[int, str] |
