diff --git a/tests/test_common.py b/tests/test_common.py index fc0a237..01ccd82 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -38,7 +38,7 @@ def setUp(self): self.setUpPyfakefs() def test_file_not_found_and_file_read(self): - # Create a file, but not the one we're looking for + # Create a mock file, but not the one we're looking for self.fs.create_file("testfile.txt", contents=b"hello") with self.assertRaises(FileNotFoundError): path2bytes("nonexistent.txt") @@ -46,6 +46,13 @@ def test_file_not_found_and_file_read(self): # Now open the file that does exist and check the contents self.assertEqual(path2bytes("testfile.txt"), b"hello") + def test_empty_file_exception(self): + # Create a mock empty file + self.fs.create_file("emptyfile.txt", contents=b"") + # We raise EOFError for empty files, and (valid) compressed files that expand to a zero-length output + with self.assertRaises(EOFError): + path2bytes("emptyfile.txt") + def test_invalid_archive_expand_exception(self): # Test that trying to unpack an archive file which isn't valid archive data, raises an exception self.fs.create_file("invalidarchive.gz", contents=b"hello")