mirror of
https://github.com/romanz/amodem.git
synced 2026-02-25 00:31:08 +08:00
add UT for wave.py
This commit is contained in:
23
tests/test_wave.py
Normal file
23
tests/test_wave.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from amodem import wave
|
||||
import subprocess as sp
|
||||
import signal
|
||||
|
||||
|
||||
def test_launch():
|
||||
p = wave.launch('cat', stdin=sp.PIPE)
|
||||
p.stdin.close()
|
||||
assert p.wait() == 0
|
||||
|
||||
p = wave.launch('bash', stdin=sp.PIPE)
|
||||
p.stdin.write(b'exit 42')
|
||||
p.stdin.close()
|
||||
assert p.wait() == 42
|
||||
|
||||
p = wave.launch('cat', stdin=sp.PIPE, stdout=sp.PIPE)
|
||||
s = b'Hello World!'
|
||||
p.stdin.write(s)
|
||||
p.stdin.flush()
|
||||
assert p.stdout.read(len(s)) == s
|
||||
|
||||
p.kill()
|
||||
assert p.wait() == -signal.SIGKILL
|
||||
Reference in New Issue
Block a user