Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7c44101
use is_extended_id instead of id_type for message objects
felixdivo Sep 6, 2018
b3fd52f
better documentation
felixdivo Sep 6, 2018
00903f8
document check option
felixdivo Sep 6, 2018
6204cda
fixes for the Message class
felixdivo Sep 6, 2018
965bbbb
run test on CI for logformats_test.py
felixdivo Sep 6, 2018
1797e43
added channel to docs
felixdivo Sep 6, 2018
e76f017
add example messages with channel attribute set
felixdivo Sep 6, 2018
4e23808
test codecov
felixdivo Sep 8, 2018
f71fd56
change logformat tests
felixdivo Sep 10, 2018
a20f4f7
nicer __repr__
felixdivo Sep 10, 2018
5217880
add __slots__, correct __hash__. deprecate id_type
felixdivo Sep 10, 2018
edb2b6e
make timestamp comparisoun a bit more forgiving
felixdivo Sep 10, 2018
ec9f9ed
use extended_id in constructor
felixdivo Sep 10, 2018
1a76644
fix TestBlfFileFormat test
felixdivo Sep 10, 2018
26b2406
implemented Message._check
felixdivo Sep 10, 2018
52ab605
adjust logformat test
felixdivo Sep 10, 2018
a724a92
Merge branch 'develop' into change-messages
felixdivo Sep 10, 2018
5d88662
try to add warning & compat __dict__
felixdivo Sep 15, 2018
c0fe8a7
Merge branch 'change-messages' of github.com:hardbyte/python-can into…
felixdivo Sep 15, 2018
5fb1775
properly implement warning
felixdivo Sep 16, 2018
eee819f
update deprecation notes
felixdivo Sep 16, 2018
00f6b92
docs & remove undocumented setting of flags in kvaser backend
felixdivo Sep 16, 2018
da6d180
docs
felixdivo Sep 16, 2018
9791761
compare by identity; add _dict to __hash__()
felixdivo Sep 23, 2018
95cc0b5
address PR comments
felixdivo Sep 23, 2018
f4c532e
remove leftover code
felixdivo Sep 23, 2018
360cfdf
Merge branch 'develop' into change-messages
felixdivo Sep 23, 2018
43586e9
resolve bad merge commit
felixdivo Sep 23, 2018
afe9cf6
added missing comma
felixdivo Sep 23, 2018
58a31f3
add __copy__ and __deepcopy__
felixdivo Sep 23, 2018
e840d36
docs
felixdivo Sep 23, 2018
e27fafb
fix bad test case
felixdivo Sep 27, 2018
196cd89
add Message.equals(), and correctly check for equality in failing tests
felixdivo Sep 27, 2018
2499c95
Merge branch 'develop' into change-messages
felixdivo Sep 27, 2018
fddef63
Merge branch 'develop' into change-messages
felixdivo Sep 27, 2018
c28a106
Remove message hash implementation
hardbyte Sep 28, 2018
5eb4fa4
Merge branch 'develop' into change-messages
hardbyte Sep 28, 2018
68d8e45
Fix missing space in setup
hardbyte Sep 28, 2018
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
Prev Previous commit
Next Next commit
change logformat tests
  • Loading branch information
felixdivo committed Sep 10, 2018
commit f71fd5696a12992c91b946916ebd2ac4488730ab
8 changes: 8 additions & 0 deletions test/data/example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,18 @@ def sort_messages(messages):
# empty data
data=[0xFF, 0xFE, 0xFD],
),
Message(
# with channel as integer
channel=0,
),
Message(
# with channel as integer
channel=42,
),
Message(
# with channel as string
channel="vcan0",
),
Message(
# with channel as string
channel="awesome_channel",
Expand Down
29 changes: 23 additions & 6 deletions test/logformats_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
different writer/reader pairs - e.g., some don't handle error frames and
comments.

TODO: correctly set preserves_channel and adds_default_channel
TODO: implement CAN FD support testing
"""

Expand Down Expand Up @@ -61,7 +62,8 @@ def _setup_instance_helper(self,
writer_constructor, reader_constructor, binary_file=False,
check_remote_frames=True, check_error_frames=True, check_fd=True,
check_comments=False, test_append=False,
round_timestamps=False, preserves_timestamp_exact=True, preserves_channel=True):
round_timestamps=False, preserves_timestamp_exact=True,
preserves_channel=True, adds_default_channel=None):
"""
:param Callable writer_constructor: the constructor of the writer class
:param Callable reader_constructor: the constructor of the reader class
Expand All @@ -81,6 +83,8 @@ def _setup_instance_helper(self,
:param bool preserves_timestamp_exact: if True, checks that timestamps match exactly
in this case, no rounding is performed
:param bool preserves_channel: if True, checks that the channel attribute is preserved
:param any adds_default_channel: sets this as the channel when not other channel was given
ignored, if *preserves_channel* is True
"""
# get all test messages
self.original_messages = TEST_MESSAGES_BASE
Expand Down Expand Up @@ -113,6 +117,7 @@ def _setup_instance_helper(self,
self.round_timestamps = round_timestamps
self.preserves_timestamp_exact = preserves_timestamp_exact
self.preserves_channel = preserves_channel
self.adds_default_channel = adds_default_channel

def setUp(self):
with tempfile.NamedTemporaryFile('w+', delete=False) as test_file:
Expand Down Expand Up @@ -305,6 +310,10 @@ def assertMessageEqual(self, message_1, message_2):
"""
Checks that two messages are equal, according to the current rules.
"""
# try conventional
if message_1 == message_2:
return

# check the timestamp
if self.preserves_timestamp_exact:
self.assertEqual(message_1.timestamp, message_2.timestamp)
Expand All @@ -323,6 +332,8 @@ def assertMessageEqual(self, message_1, message_2):
self.assertEqual(message_1.is_error_frame, message_2.is_error_frame)
if self.preserves_channel:
self.assertEqual(message_1.channel, message_2.channel)
else:
self.assertEqual(message_2.channel, self.adds_default_channel)
self.assertEqual(message_1.dlc, message_2.dlc)
self.assertEqual(message_1.data, message_2.data)
self.assertEqual(message_1.is_fd, message_2.is_fd)
Expand Down Expand Up @@ -353,7 +364,9 @@ def _setup_instance(self):
super(TestAscFileFormat, self)._setup_instance_helper(
can.ASCWriter, can.ASCReader,
check_fd=False,
check_comments=True, round_timestamps=True
check_comments=True,
round_timestamps=True,
preserves_channel=False, adds_default_channel=0
)


Expand All @@ -367,7 +380,8 @@ def _setup_instance(self):
can.BLFWriter, can.BLFReader,
binary_file=True,
check_fd=False,
check_comments=False
check_comments=False,
preserves_channel=False, adds_default_channel=0
)

def test_read_known_file(self):
Expand Down Expand Up @@ -398,7 +412,8 @@ def _setup_instance(self):
super(TestCanutilsFileFormat, self)._setup_instance_helper(
can.CanutilsLogWriter, can.CanutilsLogReader,
check_fd=False,
test_append=True, check_comments=False
test_append=True, check_comments=False,
preserves_channel=False, adds_default_channel='vcan0'
)


Expand All @@ -411,7 +426,8 @@ def _setup_instance(self):
super(TestCsvFileFormat, self)._setup_instance_helper(
can.CSVWriter, can.CSVReader,
check_fd=False,
test_append=True, check_comments=False
test_append=True, check_comments=False,
preserves_channel=False, adds_default_channel=None
)


Expand All @@ -424,7 +440,8 @@ def _setup_instance(self):
super(TestSqliteDatabaseFormat, self)._setup_instance_helper(
can.SqliteWriter, can.SqliteReader,
check_fd=False,
test_append=True, check_comments=False
test_append=True, check_comments=False,
preserves_channel=False, adds_default_channel=None
)

@unittest.skip("not implemented")
Expand Down