Skip to content

Commit

Permalink
fix slcan tests (#1834)
Browse files Browse the repository at this point in the history
  • Loading branch information
zariiii9003 authored Aug 10, 2024
1 parent 971c331 commit 30601c7
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions test/test_slcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import serial

import can
import can.interfaces.slcan

from .config import IS_PYPY

Expand Down Expand Up @@ -58,9 +58,8 @@ def test_send_extended(self):
arbitration_id=0x12ABCDEF, is_extended_id=True, data=[0xAA, 0x55]
)
self.bus.send(msg)
expected = b"T12ABCDEF2AA55\r"
data = self.serial.read(len(expected))
self.assertEqual(data, expected)
rx_msg = self.bus.recv(TIMEOUT)
self.assertTrue(msg.equals(rx_msg, timestamp_delta=None))

def test_recv_standard(self):
self.serial.write(b"t4563112233\r")
Expand All @@ -77,9 +76,8 @@ def test_send_standard(self):
arbitration_id=0x456, is_extended_id=False, data=[0x11, 0x22, 0x33]
)
self.bus.send(msg)
expected = b"t4563112233\r"
data = self.serial.read(len(expected))
self.assertEqual(data, expected)
rx_msg = self.bus.recv(TIMEOUT)
self.assertTrue(msg.equals(rx_msg, timestamp_delta=None))

def test_recv_standard_remote(self):
self.serial.write(b"r1238\r")
Expand All @@ -95,9 +93,8 @@ def test_send_standard_remote(self):
arbitration_id=0x123, is_extended_id=False, is_remote_frame=True, dlc=8
)
self.bus.send(msg)
expected = b"r1238\r"
data = self.serial.read(len(expected))
self.assertEqual(data, expected)
rx_msg = self.bus.recv(TIMEOUT)
self.assertTrue(msg.equals(rx_msg, timestamp_delta=None))

def test_recv_extended_remote(self):
self.serial.write(b"R12ABCDEF6\r")
Expand All @@ -113,9 +110,8 @@ def test_send_extended_remote(self):
arbitration_id=0x12ABCDEF, is_extended_id=True, is_remote_frame=True, dlc=6
)
self.bus.send(msg)
expected = b"R12ABCDEF6\r"
data = self.serial.read(len(expected))
self.assertEqual(data, expected)
rx_msg = self.bus.recv(TIMEOUT)
self.assertTrue(msg.equals(rx_msg, timestamp_delta=None))

def test_partial_recv(self):
self.serial.write(b"T12ABCDEF")
Expand Down

0 comments on commit 30601c7

Please sign in to comment.