1- from udsoncan .client import Client
2- from udsoncan import services
31from udsoncan .exceptions import *
42
53from test .ClientServerTest import ClientServerTest
4+ from udsoncan .configs import latest_standard
65
76class TestClearDtc (ClientServerTest ):
87 def __init__ (self , * args , ** kwargs ):
@@ -32,18 +31,28 @@ def _test_clear_dtc_spr_no_effect(self):
3231 def test_clear_dtc_all (self ):
3332 request = self .conn .touserqueue .get (timeout = 0.2 )
3433 self .assertEqual (request , b"\x14 \xFF \xFF \xFF " )
35- self .conn .fromuserqueue .put (b"\x54 " ) # Positive response
34+ self .conn .fromuserqueue .put (b"\x54 " ) # Positive response
3635
3736 def _test_clear_dtc_all (self ):
3837 response = self .udsclient .clear_dtc ()
3938 self .assertTrue (response .valid )
4039 self .assertTrue (response .positive )
4140
41+ def test_clear_dtc_with_memory_selection (self ):
42+ request = self .conn .touserqueue .get (timeout = 0.2 )
43+ self .assertEqual (request , b"\x14 \x12 \x34 \x56 \x99 " )
44+ self .conn .fromuserqueue .put (b"\x54 " ) # Positive response
45+
46+ def _test_clear_dtc_with_memory_selection (self ):
47+ response = self .udsclient .clear_dtc (group = 0x123456 , memory_selection = 0x99 )
48+ self .assertTrue (response .valid )
49+ self .assertTrue (response .positive )
50+
4251 def test_clear_dtc_denied_exception (self ):
4352 self .wait_request_and_respond (b"\x7F \x14 \x31 " ) #Request Out Of Range
4453
4554 def _test_clear_dtc_denied_exception (self ):
46- with self .assertRaises (NegativeResponseException ) as handle :
55+ with self .assertRaises (NegativeResponseException ):
4756 self .udsclient .clear_dtc (0x123456 )
4857
4958 def test_clear_dtc_denied_no_exception (self ):
@@ -60,7 +69,7 @@ def test_clear_dtc_invalidservice_exception(self):
6069 self .wait_request_and_respond (b"\x00 " ) #Inexistent Service
6170
6271 def _test_clear_dtc_invalidservice_exception (self ):
63- with self .assertRaises (InvalidResponseException ) as handle :
72+ with self .assertRaises (InvalidResponseException ):
6473 self .udsclient .clear_dtc (0x123456 )
6574
6675 def test_clear_dtc_invalidservice_no_exception (self ):
@@ -75,7 +84,7 @@ def test_clear_dtc_wrongservice_exception(self):
7584 self .wait_request_and_respond (b"\x7E \x00 " ) # Valid but wrong service (Tester Present)
7685
7786 def _test_clear_dtc_wrongservice_exception (self ):
78- with self .assertRaises (UnexpectedResponseException ) as handle :
87+ with self .assertRaises (UnexpectedResponseException ):
7988 self .udsclient .clear_dtc (0x123456 )
8089
8190 def test_clear_dtc_wrongservice_no_exception (self ):
@@ -96,3 +105,14 @@ def _test_bad_param(self):
96105
97106 with self .assertRaises (ValueError ):
98107 self .udsclient .clear_dtc (- 1 )
108+
109+ with self .assertRaises (ValueError ):
110+ self .udsclient .clear_dtc (1 , memory_selection = - 1 )
111+
112+ with self .assertRaises (ValueError ):
113+ self .udsclient .clear_dtc (1 , memory_selection = 0x100 )
114+
115+ with self .assertRaises (NotImplementedError ):
116+ self .udsclient .set_config ('standard_version' , 2013 )
117+ self .udsclient .clear_dtc (1 , memory_selection = 0x100 )
118+ self .udsclient .set_config ('standard_version' , latest_standard )
0 commit comments