Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cleanups & some docs for TestMessageClass
  • Loading branch information
felixdivo committed Feb 9, 2019
commit b3d392c91a3f0317734d18637bb92627a0c2d19c
15 changes: 6 additions & 9 deletions test/data/example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def sort_messages(messages):


# List of messages of different types that can be used in tests
TEST_MESSAGES_BASE = [
TEST_MESSAGES_BASE = sort_messages([
Message(
# empty
),
Expand Down Expand Up @@ -98,11 +98,10 @@ def sort_messages(messages):
arbitration_id=0x768, is_extended_id=False,
timestamp=TEST_TIME + 3.165
),
]
TEST_MESSAGES_BASE = sort_messages(TEST_MESSAGES_BASE)
])


TEST_MESSAGES_REMOTE_FRAMES = [
TEST_MESSAGES_REMOTE_FRAMES = sort_messages([
Message(
arbitration_id=0xDADADA, is_extended_id=True, is_remote_frame=True,
timestamp=TEST_TIME + .165,
Expand All @@ -119,11 +118,10 @@ def sort_messages(messages):
arbitration_id=0xABCDEF, is_extended_id=True, is_remote_frame=True,
timestamp=TEST_TIME + 7858.67
),
]
TEST_MESSAGES_REMOTE_FRAMES = sort_messages(TEST_MESSAGES_REMOTE_FRAMES)
])


TEST_MESSAGES_ERROR_FRAMES = [
TEST_MESSAGES_ERROR_FRAMES = sort_messages([
Message(
is_error_frame=True
),
Expand All @@ -135,8 +133,7 @@ def sort_messages(messages):
is_error_frame=True,
timestamp=TEST_TIME + 17.157
)
]
TEST_MESSAGES_ERROR_FRAMES = sort_messages(TEST_MESSAGES_ERROR_FRAMES)
])


TEST_ALL_MESSAGES = sort_messages(TEST_MESSAGES_BASE + TEST_MESSAGES_REMOTE_FRAMES + \
Expand Down
7 changes: 6 additions & 1 deletion test/test_message_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@


class TestMessageClass(unittest.TestCase):
"""
This test tries many inputs to the message class constructor and then sanity checks
all methods and ensures that nothing crashes. It also checks whether Message.check()
allows all valid can frames.
"""

@given(
timestamp=st.floats(min_value=0.0),
Expand Down Expand Up @@ -56,7 +61,7 @@ def test_methods(self, **kwargs):
normal_copy = copy(message)
deep_copy = deepcopy(message)
for other in (normal_copy, deep_copy, message):
self.assertTrue(message.equals(other), str(other))
self.assertTrue(message.equals(other))


if __name__ == '__main__':
Expand Down