Skip to content

Commit 014e85a

Browse files
committed
#267 improve expectations for interrupt tests
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent cf1daef commit 014e85a

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

tests/scancode/test_interrupt.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def some_long_function(exec_time):
7272
sleep(exec_time)
7373
return 'OK'
7474

75-
result = interrupt.interruptible(some_long_function, 0.01, timeout=5, max_memory=1024 * 1024 * 1024)
75+
result = interrupt.interruptible(some_long_function, 0.01, timeout=10, max_memory=1024 * 1024 * 1024)
7676
assert (True, 'OK') == result
7777

7878
def test_interruptible_stops_execution_on_timeout(self):
@@ -82,7 +82,7 @@ def some_long_function(exec_time):
8282
sleep(exec_time)
8383
return 'OK'
8484

85-
result = interrupt.interruptible(some_long_function, 0.5, timeout=0.1)
85+
result = interrupt.interruptible(some_long_function, 0.5, timeout=0.01)
8686
assert (False, 'Processing interrupted: timeout after 0 seconds.') == result
8787

8888
def test_interruptible_stops_execution_on_memory(self):
@@ -94,9 +94,6 @@ def some_hungry_function(exec_time):
9494
_ram = range(1000000)
9595
return 'OK'
9696

97-
process = psutil.Process()
98-
current_memory = process.memory_info().rss
99-
100-
success, result = interrupt.interruptible(some_hungry_function, 0.1, timeout=5, max_memory=current_memory + 1000)
97+
success, result = interrupt.interruptible(some_hungry_function, 0.1, timeout=5, max_memory=1000)
10198
assert success == False
10299
assert 'Processing interrupted: excessive memory usage of more than' in result

0 commit comments

Comments
 (0)