Skip to content

Commit e522e39

Browse files
authored
Fix TRC test (hardbyte#1561)
1 parent f004edb commit e522e39

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

can/io/trc.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
for file format description
66
77
Version 1.1 will be implemented as it is most commonly used
8-
""" # noqa
8+
"""
99

10-
import io
1110
import logging
1211
import os
1312
from datetime import datetime, timedelta, timezone
@@ -274,7 +273,7 @@ def __init__(
274273
super().__init__(file, mode="w")
275274
self.channel = channel
276275

277-
if isinstance(self.file, io.TextIOWrapper):
276+
if hasattr(self.file, "reconfigure"):
278277
self.file.reconfigure(newline="\r\n")
279278
else:
280279
raise TypeError("File must be opened in text mode.")

test/logformats_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,10 +934,11 @@ def msg_ext(timestamp):
934934
self.assertMessagesEqual(actual, expected_messages)
935935

936936
def test_not_supported_version(self):
937-
with self.assertRaises(NotImplementedError):
938-
writer = can.TRCWriter("test.trc")
939-
writer.file_version = can.TRCFileVersion.UNKNOWN
940-
writer.on_message_received(can.Message())
937+
with tempfile.NamedTemporaryFile(mode="w") as f:
938+
with self.assertRaises(NotImplementedError):
939+
writer = can.TRCWriter(f)
940+
writer.file_version = can.TRCFileVersion.UNKNOWN
941+
writer.on_message_received(can.Message())
941942

942943

943944
class TestTrcFileFormatV1_0(TestTrcFileFormatBase):

0 commit comments

Comments
 (0)