@@ -33,16 +33,17 @@ def test_osi_trace_sv(self):
3333
3434 trace = OSITrace (path_input )
3535 with open (path_output , "wt" ) as f :
36+ count = 0
3637 for message in trace :
3738 self .assertIsInstance (message , SensorView )
39+ count += 1
3840 f .write (str (message ))
41+ self .assertEqual (count , 10 )
3942
4043 with warnings .catch_warnings ():
4144 warnings .simplefilter ("ignore" )
42- try :
45+ with self . assertRaises ( NotImplementedError ) :
4346 self .assertEqual (len (trace .retrieve_offsets ()), 10 )
44- except NotImplementedError :
45- pass
4647 trace .close ()
4748
4849 self .assertTrue (os .path .exists (path_output ))
@@ -55,16 +56,17 @@ def test_osi_trace_svc(self):
5556
5657 trace = OSITrace (path_input , "SensorViewConfiguration" )
5758 with open (path_output , "wt" ) as f :
59+ count = 0
5860 for message in trace :
5961 self .assertIsInstance (message , SensorViewConfiguration )
62+ count += 1
6063 f .write (str (message ))
64+ self .assertEqual (count , 1 )
6165
6266 with warnings .catch_warnings ():
6367 warnings .simplefilter ("ignore" )
64- try :
65- self .assertEqual (len (trace .retrieve_offsets ()), 10 )
66- except NotImplementedError :
67- pass
68+ with self .assertRaises (NotImplementedError ):
69+ self .assertEqual (len (trace .retrieve_offsets ()), 1 )
6870 trace .close ()
6971
7072 self .assertTrue (os .path .exists (path_output ))
@@ -77,16 +79,17 @@ def test_osi_trace_gt(self):
7779
7880 trace = OSITrace (path_input , "GroundTruth" )
7981 with open (path_output , "wt" ) as f :
82+ count = 0
8083 for message in trace :
8184 self .assertIsInstance (message , GroundTruth )
85+ count += 1
8286 f .write (str (message ))
87+ self .assertEqual (count , 10 )
8388
8489 with warnings .catch_warnings ():
8590 warnings .simplefilter ("ignore" )
86- try :
91+ with self . assertRaises ( NotImplementedError ) :
8792 self .assertEqual (len (trace .retrieve_offsets ()), 10 )
88- except NotImplementedError :
89- pass
9093 trace .close ()
9194
9295 self .assertTrue (os .path .exists (path_output ))
@@ -99,16 +102,17 @@ def test_osi_trace_hvd(self):
99102
100103 trace = OSITrace (path_input , "HostVehicleData" )
101104 with open (path_output , "wt" ) as f :
105+ count = 0
102106 for message in trace :
103107 self .assertIsInstance (message , HostVehicleData )
108+ count += 1
104109 f .write (str (message ))
110+ self .assertEqual (count , 10 )
105111
106112 with warnings .catch_warnings ():
107113 warnings .simplefilter ("ignore" )
108- try :
114+ with self . assertRaises ( NotImplementedError ) :
109115 self .assertEqual (len (trace .retrieve_offsets ()), 10 )
110- except NotImplementedError :
111- pass
112116 trace .close ()
113117
114118 self .assertTrue (os .path .exists (path_output ))
@@ -121,16 +125,17 @@ def test_osi_trace_sd(self):
121125
122126 trace = OSITrace (path_input , "SensorData" )
123127 with open (path_output , "wt" ) as f :
128+ count = 0
124129 for message in trace :
125130 self .assertIsInstance (message , SensorData )
131+ count += 1
126132 f .write (str (message ))
133+ self .assertEqual (count , 10 )
127134
128135 with warnings .catch_warnings ():
129136 warnings .simplefilter ("ignore" )
130- try :
137+ with self . assertRaises ( NotImplementedError ) :
131138 self .assertEqual (len (trace .retrieve_offsets ()), 10 )
132- except NotImplementedError :
133- pass
134139 trace .close ()
135140
136141 self .assertTrue (os .path .exists (path_output ))
@@ -143,16 +148,17 @@ def test_osi_trace_tc(self):
143148
144149 trace = OSITrace (path_input , "TrafficCommand" )
145150 with open (path_output , "wt" ) as f :
151+ count = 0
146152 for message in trace :
147153 self .assertIsInstance (message , TrafficCommand )
154+ count += 1
148155 f .write (str (message ))
156+ self .assertEqual (count , 10 )
149157
150158 with warnings .catch_warnings ():
151159 warnings .simplefilter ("ignore" )
152- try :
160+ with self . assertRaises ( NotImplementedError ) :
153161 self .assertEqual (len (trace .retrieve_offsets ()), 10 )
154- except NotImplementedError :
155- pass
156162 trace .close ()
157163
158164 self .assertTrue (os .path .exists (path_output ))
@@ -165,16 +171,17 @@ def test_osi_trace_tcu(self):
165171
166172 trace = OSITrace (path_input , "TrafficCommandUpdate" )
167173 with open (path_output , "wt" ) as f :
174+ count = 0
168175 for message in trace :
169176 self .assertIsInstance (message , TrafficCommandUpdate )
177+ count += 1
170178 f .write (str (message ))
179+ self .assertEqual (count , 10 )
171180
172181 with warnings .catch_warnings ():
173182 warnings .simplefilter ("ignore" )
174- try :
183+ with self . assertRaises ( NotImplementedError ) :
175184 self .assertEqual (len (trace .retrieve_offsets ()), 10 )
176- except NotImplementedError :
177- pass
178185 trace .close ()
179186
180187 self .assertTrue (os .path .exists (path_output ))
@@ -187,16 +194,17 @@ def test_osi_trace_tu(self):
187194
188195 trace = OSITrace (path_input , "TrafficUpdate" )
189196 with open (path_output , "wt" ) as f :
197+ count = 0
190198 for message in trace :
191199 self .assertIsInstance (message , TrafficUpdate )
200+ count += 1
192201 f .write (str (message ))
202+ self .assertEqual (count , 10 )
193203
194204 with warnings .catch_warnings ():
195205 warnings .simplefilter ("ignore" )
196- try :
206+ with self . assertRaises ( NotImplementedError ) :
197207 self .assertEqual (len (trace .retrieve_offsets ()), 10 )
198- except NotImplementedError :
199- pass
200208 trace .close ()
201209
202210 self .assertTrue (os .path .exists (path_output ))
@@ -209,16 +217,17 @@ def test_osi_trace_mr(self):
209217
210218 trace = OSITrace (path_input , "MotionRequest" )
211219 with open (path_output , "wt" ) as f :
220+ count = 0
212221 for message in trace :
213222 self .assertIsInstance (message , MotionRequest )
223+ count += 1
214224 f .write (str (message ))
225+ self .assertEqual (count , 10 )
215226
216227 with warnings .catch_warnings ():
217228 warnings .simplefilter ("ignore" )
218- try :
229+ with self . assertRaises ( NotImplementedError ) :
219230 self .assertEqual (len (trace .retrieve_offsets ()), 10 )
220- except NotImplementedError :
221- pass
222231 trace .close ()
223232
224233 self .assertTrue (os .path .exists (path_output ))
@@ -231,16 +240,17 @@ def test_osi_trace_su(self):
231240
232241 trace = OSITrace (path_input , "StreamingUpdate" )
233242 with open (path_output , "wt" ) as f :
243+ count = 0
234244 for message in trace :
235245 self .assertIsInstance (message , StreamingUpdate )
246+ count += 1
236247 f .write (str (message ))
248+ self .assertEqual (count , 10 )
237249
238250 with warnings .catch_warnings ():
239251 warnings .simplefilter ("ignore" )
240- try :
252+ with self . assertRaises ( NotImplementedError ) :
241253 self .assertEqual (len (trace .retrieve_offsets ()), 10 )
242- except NotImplementedError :
243- pass
244254 trace .close ()
245255
246256 self .assertTrue (os .path .exists (path_output ))
0 commit comments