aboutsummaryrefslogtreecommitdiff
path: root/tests/test_validations.py
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-11-14 16:44:34 -0800
committerCody Logan <cody@lokken.dev>2023-11-14 16:44:34 -0800
commit605085c95fe5ab6af337aefc723794f78cf3dfd7 (patch)
treef0dfba6e4fe1fa71a0ba48ecd6f098c66c03f30e /tests/test_validations.py
parent733eeb27581ee6fc2a9c2d79d7b002127bde85f1 (diff)
downloadwikiget-605085c95fe5ab6af337aefc723794f78cf3dfd7.tar.gz
wikiget-605085c95fe5ab6af337aefc723794f78cf3dfd7.zip
Use fixtures to create test files
This reduces the number of temporary folders and files created during testing. Additionally, an actual JPEG is created for a couple tests instead of using random text for the contents.
Diffstat (limited to 'tests/test_validations.py')
-rw-r--r--tests/test_validations.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/tests/test_validations.py b/tests/test_validations.py
index 161d102..aa4fdd0 100644
--- a/tests/test_validations.py
+++ b/tests/test_validations.py
@@ -163,14 +163,11 @@ class TestFileInput:
class TestVerifyHash:
"""Define tests related to wikiget.validations.verify_hash."""
- def test_verify_hash(self, tmp_path: Path) -> None:
- """Confirm that verify_hash returns the proper SHA1 hash."""
- file_name = "testfile"
- file_contents = "foobar"
- file_sha1 = "8843d7f92416211de9ebb963ff4ce28125932878"
+ def test_verify_hash(self, test_file: Path) -> None:
+ """Confirm that verify_hash returns the proper SHA1 hash.
- # create a temporary file with known contents
- tmp_file = tmp_path / file_name
- tmp_file.write_text(file_contents)
+ The test file used here is generated by a fixture in conftest.py.
+ """
+ expected_sha1 = "cd19c009a30ca9b68045415a3a0838e64f3c2443"
- assert verify_hash(str(tmp_file)) == file_sha1
+ assert verify_hash(str(test_file)) == expected_sha1