This repository was archived by the owner on Nov 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ def append(self, value):
203203 if value .time_elapsed < self .rtt_min :
204204 self .rtt_min = value .time_elapsed
205205
206- self .packets_lost = self .packets_lost + (0 if value .success else 1 - self .packets_lost ) / len (self )
206+ self .packets_lost = self .packets_lost + (( 0 if value .success else 1 ) - self .packets_lost ) / len (self )
207207
208208 if self .verbose :
209209 print (value , file = self .output )
Original file line number Diff line number Diff line change @@ -289,6 +289,20 @@ def test_some_packets_lost(self):
289289 "Unable to calculate packet loss correctly when some of the responses failed"
290290 )
291291
292+ def test_some_packets_lost_mixed (self ):
293+ rs = executor .ResponseList ([
294+ FailingResponseMock (None , 1 ),
295+ SuccessfulResponseMock (None , 1 ),
296+ FailingResponseMock (None , 1 ),
297+ SuccessfulResponseMock (None , 1 ),
298+ ])
299+
300+ self .assertEqual (
301+ rs .packet_loss ,
302+ 0.5 ,
303+ "Unable to calculate packet loss correctly when failing responses are mixed with successful responses"
304+ )
305+
292306
293307class CommunicatorTestCase (unittest .TestCase ):
294308 """Tests for Communicator"""
You can’t perform that action at this time.
0 commit comments