aboutsummaryrefslogtreecommitdiffstats
path: root/test/netlib/test_version_check.py
blob: 01820dad887797cca8834d88cf1b03fafbfa53ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import io
import mock
from netlib import version_check


@mock.patch("sys.exit")
def test_check_pyopenssl_version(sexit):
    fp = io.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 "outdated" in fp.getvalue()
    assert sexit.called


@mock.patch("sys.exit")
@mock.patch("OpenSSL.__version__")
def test_unparseable_pyopenssl_version(version, sexit):
    version.split.return_value = ["foo", "bar"]
    fp = io.StringIO()
    version_check.check_pyopenssl_version(fp=fp)
    assert "Cannot parse" in fp.getvalue()
    assert not sexit.called