mitmproxy/test/test_version_check.py

29 lines
760 B
Python
Raw Normal View History

import cStringIO
import mock
from netlib import version_check, version
@mock.patch("sys.exit")
2015-08-03 16:06:31 +00:00
def test_check_mitmproxy_version(sexit):
fp = cStringIO.StringIO()
2015-08-03 16:06:31 +00:00
version_check.check_mitmproxy_version(version.IVERSION, fp=fp)
assert not fp.getvalue()
assert not sexit.called
b = (version.IVERSION[0] - 1, version.IVERSION[1])
2015-08-03 16:06:31 +00:00
version_check.check_mitmproxy_version(b, fp=fp)
assert fp.getvalue()
assert sexit.called
2015-08-03 16:06:31 +00:00
@mock.patch("sys.exit")
def test_check_pyopenssl_version(sexit):
fp = cStringIO.StringIO()
version_check.check_pyopenssl_version(fp=fp)
assert not fp.getvalue()
assert not sexit.called
version_check.check_pyopenssl_version((9999,), fp=fp)
assert fp.getvalue()
assert sexit.called