Skip to content

Commit

Permalink
fix append test for lower python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Nov 20, 2022
1 parent 52e86ca commit 79f5905
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/unit/test_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import unittest

from dune_client.file.base import CSVFile, NDJSONFile, JSONFile
Expand Down Expand Up @@ -151,8 +152,17 @@ def test_not_skip_empty_when_specified(self):
# CSV empty files won't have any headers!
self.file_manager._write([], writer, False)
else:
with self.assertNoLogs():
if sys.version_info < (3, 10):
with self.assertRaises(FileNotFoundError):
self.file_manager._load(writer)
# assertNoLogs didn't exist till python 3.10, but we still support lower versions.
# This is a bit of a hack, we write and then load to ensure the empty file was written.
self.file_manager._write([], writer, False)
# _load would return FileNotFoundError if it hadn't been written
self.assertEqual(0, len(self.file_manager._load(writer)))
else:
with self.assertNoLogs():
self.file_manager._write([], writer, False)

self.file_manager._load(writer)

Expand Down

0 comments on commit 79f5905

Please sign in to comment.