Skip to content

Commit

Permalink
loose the time limits in test_exec_proc.py
Browse files Browse the repository at this point in the history
  • Loading branch information
haowen-xu committed Jul 18, 2018
1 parent 0bfc736 commit 413f1b7
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions tests/utils/test_exec_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def test_timed_wait_proc(self):
# test wait
wait_time = -time.time()
proc = subprocess.Popen(
[sys.executable, '-c', 'import sys, time; time.sleep(3); '
[sys.executable, '-c', 'import sys, time; time.sleep(10); '
'sys.exit(123)'])
self.assertIsNone(timed_wait_proc(proc, 1.5))
wait_time += time.time()
self.assertGreater(wait_time, 1.)
self.assertLess(wait_time, 2.)
self.assertLess(wait_time, 3.)


class ExcProcTestCase(unittest.TestCase):
Expand Down Expand Up @@ -94,29 +94,22 @@ def test_exec_proc_kill(self):

# test interruptable
stdout = io.BytesIO()
wait_time = -time.time()
with exec_proc(
['python', '-u', '-c', interruptable],
on_stdout=stdout.write) as proc:
timed_wait_proc(proc, 1.)
wait_time += time.time()
self.assertEquals(b'kbd interrupt\nexited\n', stdout.getvalue())
self.assertEquals(0, proc.poll())
self.assertLess(wait_time, 1.5)

# test non-interruptable, give up waiting
stdout = io.BytesIO()
wait_time = -time.time()
with exec_proc(
['python', '-u', '-c', non_interruptable],
on_stdout=stdout.write,
ctrl_c_timeout=1) as proc:
timed_wait_proc(proc, 1.)
wait_time += time.time()
self.assertEquals(b'kbd interrupt\n', stdout.getvalue())
self.assertNotEquals(0, proc.poll())
self.assertGreaterEqual(wait_time, 2.) # timed_wait + ctrl_c
self.assertLess(wait_time, 2.5)


if __name__ == '__main__':
Expand Down

0 comments on commit 413f1b7

Please sign in to comment.