Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove temporary files created in EDS tests #482

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
erlend-aasland marked this conversation as resolved.
Show resolved Hide resolved
for dest in "filename", None, filelike_object:
with self.subTest(dest=dest):
with self.assertRaisesRegex(ValueError, "'unknown'"):
Expand Down
Loading