Skip to content

Commit c151e7c

Browse files
Merge pull request #91 from RickMeasham/fix-error-template
fix: Template on empty/unreadable file exception is a string, not a float
2 parents d3656af + 47ade19 commit c151e7c

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

icalevents/icaldownload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def data_from_file(self, file, apple_fix=False):
8282
content = f.read()
8383

8484
if not content:
85-
raise IOError("File %f is not readable or is empty!" % file)
85+
raise IOError("File %s is not readable or is empty!" % file)
8686

8787
return self.decode(content, apple_fix=apple_fix)
8888

test/test_data/empty.ics

Whitespace-only changes.

test/test_icaldownload.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,14 @@ def test_read_only_directory(self):
9393
# Delete tmp dir
9494
os.chdir("..")
9595
shutil.rmtree("tmp")
96+
97+
def test_empty_file(self):
98+
empty_ical = "test/test_data/empty.ics"
99+
100+
with self.assertRaises(IOError) as cm:
101+
icalevents.icaldownload.ICalDownload().data_from_file(empty_ical)
102+
103+
self.assertEqual(
104+
str(cm.exception),
105+
"File test/test_data/empty.ics is not readable or is empty!",
106+
)

0 commit comments

Comments
 (0)