Ejemplo n.º 1
0
def _check_warning(w):
    assert issubclass(w.category, UserWarning)

    warning_match = _WARNING_RE.match(str(w.message))
    assert warning_match is not None
    (detect_ver_str, older_newer, used_ver_str) = warning_match.groups()

    return (older_newer, Version(detect_ver_str), Version(used_ver_str))
Ejemplo n.º 2
0
def test_unsupported_old():
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        assert Version.nearest("1.0") == Version("2.0")

        # Check we got a warning for that old crusty version.
        assert len(w) == 1
        (older_newer, detect_ver, used_ver) = _check_warning(w[-1])
        assert older_newer == 'newer'
        assert used_ver == Version('2.0')
Ejemplo n.º 3
0
def test_unsupported_bleedingedge():
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        assert Version.nearest("9999.9999") == Version("3.0")

        # Check we got a warning for that bleeding edge version.
        assert len(w) == 1
        (older_newer, detect_ver, used_ver) = _check_warning(w[-1])
        assert older_newer == 'older'
        assert used_ver == Version('3.0')
Ejemplo n.º 4
0
def test_grid_append_nover_list():
    g = Grid()
    assert g.version == Version('2.0')
    g.column['test'] = {}

    row_1 = {'test': 'This is a test'}
    row_2 = {'test': ['This should fail']}
    g.append(row_1)
    assert g.version == Version('2.0')
    g.append(row_2)
    assert g.version == Version('3.0')
Ejemplo n.º 5
0
def test_unsupported_newer():
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        assert Version.nearest("2.5") == Version("3.0")

        # Work around Python 2.7 bug (https://stackoverflow.com/questions/56821539/warnings-simplefilteralways-is-not-forcing-warnings-to-be-made-in-python-2-7)
        if sys.version_info[0:2] != (2, 7):
            # Check we got a warning for that oddball newer version.
            assert len(w) == 1
            (older_newer, detect_ver, used_ver) = _check_warning(w[-1])
            assert older_newer == 'newer'
            assert used_ver == Version('3.0')
Ejemplo n.º 6
0
def test_version_gt():
    assert Version('1.0') > Version('0.9')
    assert Version('1.0a') > Version('1.0')
    assert Version('1.0b') > Version('1.0a')
Ejemplo n.º 7
0
def test_version_ge():
    assert Version('1.0') >= Version('1.0')
    assert Version('1.0') >= Version('0.9')
Ejemplo n.º 8
0
def test_version_le():
    assert Version('1.0') <= Version('1.0')
    assert Version('1.0') <= Version('1.5')
Ejemplo n.º 9
0
def test_version_lt():
    assert Version('1.0') < Version('1.1')
    assert Version('1.9') < Version('1.10')
    assert Version('1.0') < Version('1.0a')
    assert Version('1.0a') < Version('1.0b')
Ejemplo n.º 10
0
def test_version_ne():
    assert Version('1.1') != Version('2.2')
    assert Version('1.0a') != Version('1.0')
Ejemplo n.º 11
0
def test_version_eq():
    assert Version('1') == Version('1.0')
    assert Version('1.0') == Version('1.0.0')
    assert Version('1.0a') == Version('1.0.0a')
Ejemplo n.º 12
0
def test_str_cmp():
    assert Version('1.0') == '1.0'
Ejemplo n.º 13
0
def test_str():
    assert str(Version('1.0')) == '1.0'
    assert str(Version('1.0a')) == '1.0a'
Ejemplo n.º 14
0
def test_malformed():
    try:
        Version('this is not a valid string')
        assert False, 'Accepted a bogus version string'
    except ValueError:
        pass