Esempio n. 1
0
def test_validate_int_min():
    goods = [
        PseudoSection('', '0', mini=0),
        PseudoSection('', '1', mini=1), PseudoSection('', '-1', mini=-1),
    ]
    bads = [
        PseudoSection('', '1', mini=2),
        PseudoSection('', '0', mini=1),
    ]
    for sec in bads:
        valid, reason = con._validate_int(sec, sec.key, minimum=sec.mini)
        assert not valid, '{} should not have been a valid '\
            'int'.format(sec.value)
    for sec in goods:
        valid, reason = con._validate_int(sec, sec.key, minimum=sec.mini)
        assert valid, '{} should have been a valid int, but '\
            'got: {}'.format(sec.value, reason)
Esempio n. 2
0
def test_validate_int_simple():
    bads = [
        PseudoSection('', 'NotAInt'),
        PseudoSection('', '-0.1'), PseudoSection('', '0.1'),
    ]
    goods = [
        PseudoSection('', '0'),
        PseudoSection('', '1'), PseudoSection('', '-1'),
        PseudoSection('', '100000000'), PseudoSection('', '-1000000000'),
        PseudoSection('', '+0'), PseudoSection('', '-0'),
    ]
    for sec in bads:
        valid, reason = con._validate_int(sec, sec.key)
        assert not valid, '{} should not have been a valid '\
            'int'.format(sec.value)
    for sec in goods:
        valid, reason = con._validate_int(sec, sec.key)
        assert valid, '{} should have been a valid int, but '\
            'got: {}'.format(sec.value, reason)