File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,8 @@ def retrieve_offsets(self, limit=None):
55
55
if not self .read_complete :
56
56
self .current_index = len (self .message_offsets ) - 1
57
57
self .file .seek (self .message_offsets [- 1 ], 0 )
58
- while (
59
- not self . read_complete and not limit or len (self .message_offsets ) <= limit
58
+ while not self . read_complete and (
59
+ not limit or len (self .message_offsets ) <= limit
60
60
):
61
61
self .retrieve_message (skip = True )
62
62
return self .message_offsets
Original file line number Diff line number Diff line change @@ -22,6 +22,20 @@ def test_osi_trace(self):
22
22
23
23
self .assertTrue (os .path .exists (path_output ))
24
24
25
+ def test_osi_trace_offsets_robustness (self ):
26
+ with tempfile .TemporaryDirectory () as tmpdirname :
27
+ path_input = os .path .join (tmpdirname , "input.osi" )
28
+ create_sample (path_input )
29
+
30
+ trace = OSITrace (path_input )
31
+ # Test whether the function can handle be run multiple times safely
32
+ offsets = trace .retrieve_offsets (None )
33
+ offsets2 = trace .retrieve_offsets (None )
34
+ trace .close ()
35
+
36
+ self .assertEqual (len (offsets ), 10 )
37
+ self .assertEqual (offsets , offsets2 )
38
+
25
39
26
40
def create_sample (path ):
27
41
f = open (path , "ab" )
You can’t perform that action at this time.
0 commit comments