Skip to content

Commit

Permalink
Remove temporary files created in EDS tests (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinse authored Jul 2, 2024
2 parents e3af0eb + 65bfaab commit 92a6e11
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/test_eds.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ def test_comments(self):

def test_export_eds_to_file(self):
import tempfile
for suffix in "eds", "dcf":
for suffix in ".eds", ".dcf":
for implicit in True, False:
with tempfile.NamedTemporaryFile() as fn:
dest = f"{fn.name}.{suffix}"
doctype = None if implicit else suffix
with tempfile.NamedTemporaryFile(suffix=suffix) as tmp:
dest = tmp.name
doctype = None if implicit else suffix[1:]
with self.subTest(dest=dest, doctype=doctype):
canopen.export_od(self.od, dest, doctype)
self.verify_od(dest, doctype)
Expand All @@ -198,8 +198,8 @@ def test_export_eds_to_file_unknown_extension(self):
import io
import tempfile
for suffix in ".txt", "":
with tempfile.NamedTemporaryFile() as fn:
dest = f"{fn.name}{suffix}"
with tempfile.NamedTemporaryFile(suffix=suffix) as tmp:
dest = tmp.name
with self.subTest(dest=dest, doctype=None):
canopen.export_od(self.od, dest)

Expand All @@ -222,6 +222,7 @@ def test_export_eds_unknown_doctype(self):
import io
filelike_object = io.StringIO()
self.addCleanup(filelike_object.close)
self.addCleanup(os.unlink, "filename")
for dest in "filename", None, filelike_object:
with self.subTest(dest=dest):
with self.assertRaisesRegex(ValueError, "'unknown'"):
Expand Down

0 comments on commit 92a6e11

Please sign in to comment.