Skip to content

Commit 71da1bc

Browse files
Remove temporary files created in EDS tests
Clean-up post #474
1 parent e3af0eb commit 71da1bc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test/test_eds.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ def test_comments(self):
185185

186186
def test_export_eds_to_file(self):
187187
import tempfile
188-
for suffix in "eds", "dcf":
188+
for suffix in ".eds", ".dcf":
189189
for implicit in True, False:
190-
with tempfile.NamedTemporaryFile() as fn:
191-
dest = f"{fn.name}.{suffix}"
192-
doctype = None if implicit else suffix
190+
with tempfile.NamedTemporaryFile(suffix=suffix) as tmp:
191+
doctype = None if implicit else suffix[1:]
192+
dest = tmp.name
193193
with self.subTest(dest=dest, doctype=doctype):
194194
canopen.export_od(self.od, dest, doctype)
195195
self.verify_od(dest, doctype)
@@ -198,8 +198,8 @@ def test_export_eds_to_file_unknown_extension(self):
198198
import io
199199
import tempfile
200200
for suffix in ".txt", "":
201-
with tempfile.NamedTemporaryFile() as fn:
202-
dest = f"{fn.name}{suffix}"
201+
with tempfile.NamedTemporaryFile(suffix=suffix) as tmp:
202+
dest = tmp.name
203203
with self.subTest(dest=dest, doctype=None):
204204
canopen.export_od(self.od, dest)
205205

@@ -222,6 +222,7 @@ def test_export_eds_unknown_doctype(self):
222222
import io
223223
filelike_object = io.StringIO()
224224
self.addCleanup(filelike_object.close)
225+
self.addCleanup(os.unlink, "filename")
225226
for dest in "filename", None, filelike_object:
226227
with self.subTest(dest=dest):
227228
with self.assertRaisesRegex(ValueError, "'unknown'"):

0 commit comments

Comments
 (0)