Skip to content

Commit

Permalink
test: longer sleeps
Browse files Browse the repository at this point in the history
  • Loading branch information
ponty committed Feb 26, 2023
1 parent 1559e8c commit 8a5e632
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions tests/test_fast/test_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def test_call():

def test_start():
p = EasyProcess("ls -la").start()
time.sleep(0.2)
time.sleep(2)
assert p.stop().return_code == 0


def test_start2():
p = EasyProcess("echo hi").start()
time.sleep(0.2)
time.sleep(2)
# no wait() -> no results
assert p.return_code is None
assert p.stdout is None
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_parse():

def test_stop():
p = EasyProcess("ls -la").start()
time.sleep(0.2)
time.sleep(2)
assert p.stop().return_code == 0
assert p.stop().return_code == 0
assert p.stop().return_code == 0
6 changes: 3 additions & 3 deletions tests/test_fast/test_returncode.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

def test_return_code():
# process has finished but no stop() or wait() was called
assert EasyProcess("echo hello").start().sleep(0.5).return_code is None
assert EasyProcess("echo hello").start().sleep(2).return_code is None

# wait()
assert EasyProcess("echo hello").start().wait().return_code == 0

# stop() after process has finished
assert EasyProcess("echo hello").start().sleep(0.5).stop().return_code == 0
assert EasyProcess("echo hello").start().sleep(2).stop().return_code == 0

# stop() before process has finished
assert EasyProcess("sleep 2").start().stop().return_code != 0
Expand All @@ -20,7 +20,7 @@ def test_return_code():

def test_is_alive1():
# early exit
p = EasyProcess("echo hello").start().sleep(0.5)
p = EasyProcess("echo hello").start().sleep(2)

assert p.return_code is None
assert p.stdout is None
Expand Down
18 changes: 9 additions & 9 deletions tests/test_fast/test_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@


def test_timeout():
p = EasyProcess("sleep 1").start()
p.wait(0.2)
p = EasyProcess("sleep 5").start()
p.wait(2)
assert p.is_alive()
p.wait(0.2)
p.wait(2)
assert p.is_alive()
p.wait(2)
assert not p.is_alive()

assert EasyProcess("sleep 0.3").call().return_code == 0
assert EasyProcess("sleep 0.3").call(timeout=0.1).return_code != 0
assert EasyProcess("sleep 0.3").call(timeout=1).return_code == 0
assert EasyProcess("sleep 2").call().return_code == 0
assert EasyProcess("sleep 2").call(timeout=1).return_code != 0
assert EasyProcess("sleep 2").call(timeout=3).return_code == 0

assert EasyProcess("sleep 0.3").call().timeout_happened is False
assert EasyProcess("sleep 0.3").call(timeout=0.1).timeout_happened
assert EasyProcess("sleep 0.3").call(timeout=1).timeout_happened is False
assert EasyProcess("sleep 2").call().timeout_happened is False
assert EasyProcess("sleep 2").call(timeout=1).timeout_happened
assert EasyProcess("sleep 2").call(timeout=3).timeout_happened is False


@pytest.mark.timeout(10)
Expand Down

0 comments on commit 8a5e632

Please sign in to comment.