add test_calib.py

This commit is contained in:
Roman Zeyde
2014-08-08 14:55:11 +03:00
parent 85f97b5e1c
commit 03a83c9a4c
2 changed files with 40 additions and 3 deletions

35
tests/test_calib.py Normal file
View File

@@ -0,0 +1,35 @@
from amodem import calib
from io import BytesIO
class ProcessMock(object):
def __init__(self):
self.buf = BytesIO()
self.stdin = self
self.stdout = self
def __call__(self, *args, **kwargs):
return self
def kill(self):
pass
def write(self, data):
self.buf.write(data)
if self.buf.tell() > 1e6:
raise KeyboardInterrupt
def read(self, n):
return self.buf.read(n)
def verify(msg):
assert msg == calib.fmt.format(1, 1, 0, 1)
def test():
p = ProcessMock()
calib.send(p)
p.buf.seek(0)
calib.recv(p, reporter=verify)