File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import json
66import base64
77from dateutil .tz import tzutc
8- from requests . auth import HTTPBasicAuth
8+
99from requests import sessions
1010
1111from segment .analytics .version import VERSION
@@ -30,7 +30,8 @@ def parse_retry_after(response):
3030 try :
3131 # Try parsing as integer (delay in seconds)
3232 delay = int (retry_after )
33- return min (delay , MAX_RETRY_AFTER_SECONDS )
33+ # Ensure delay is non-negative before applying upper bound
34+ return min (max (delay , 0 ), MAX_RETRY_AFTER_SECONDS )
3435 except ValueError :
3536 # Could be HTTP-date format, but for simplicity we'll skip that
3637 # Most APIs use integer seconds
Original file line number Diff line number Diff line change @@ -490,10 +490,8 @@ def mock_post_fn(*args, **kwargs):
490490 raise FatalError ('Fatal error occurred' )
491491
492492 with mock .patch ('segment.analytics.consumer.post' , side_effect = mock_post_fn ):
493- try :
493+ with self . assertRaises ( FatalError ) :
494494 consumer .request ([track ])
495- except FatalError :
496- pass
497495
498496 # Should only be called once (no retries)
499497 self .assertEqual (call_count , 1 )
You can’t perform that action at this time.
0 commit comments