Exemplo n.º 1
0
def test_parsenumber():

    assert parsenumber('1') == 1
    assert parsenumber('1.0') == 1.0
    assert parsenumber(str(sys.maxint + 1)) == sys.maxint + 1
    assert parsenumber('3+4j') == 3 + 4j
    assert parsenumber('aaa') == 'aaa'
    assert parsenumber(None) == None
Exemplo n.º 2
0
def test_parsenumber():
    
    assert parsenumber('1') == 1
    assert parsenumber('1.0') == 1.0
    assert parsenumber(str(sys.maxsize + 1)) == sys.maxsize + 1
    assert parsenumber('3+4j') == 3 + 4j
    assert parsenumber('aaa') == 'aaa'
    assert parsenumber(None) == None
Exemplo n.º 3
0
def test_parsenumber():

    assert parsenumber("1") == 1
    assert parsenumber("1.0") == 1.0
    assert parsenumber(str(sys.maxint + 1)) == sys.maxint + 1
    assert parsenumber("3+4j") == 3 + 4j
    assert parsenumber("aaa") == "aaa"
    assert parsenumber(None) == None
Exemplo n.º 4
0
def test_parsenumber_strict():

    assert parsenumber('1', strict=True) == 1
    assert parsenumber('1.0', strict=True) == 1.0
    assert parsenumber(str(sys.maxint + 1), strict=True) == sys.maxint + 1
    assert parsenumber('3+4j', strict=True) == 3 + 4j
    try:
        parsenumber('aaa', strict=True)
    except:
        pass  # expected
    else:
        assert False, 'expected exception'
    try:
        parsenumber(None, strict=True)
    except:
        pass  # expected
    else:
        assert False, 'expected exception'
Exemplo n.º 5
0
def test_parsenumber_strict():
    
    assert parsenumber('1', strict=True) == 1
    assert parsenumber('1.0', strict=True) == 1.0
    assert parsenumber(str(sys.maxsize + 1), strict=True) == sys.maxsize + 1
    assert parsenumber('3+4j', strict=True) == 3 + 4j
    try:
        parsenumber('aaa', strict=True)
    except:
        pass # expected
    else:
        assert False, 'expected exception'
    try:
        parsenumber(None, strict=True)
    except:
        pass # expected
    else:
        assert False, 'expected exception'
Exemplo n.º 6
0
def test_parsenumber_strict():

    assert parsenumber("1", strict=True) == 1
    assert parsenumber("1.0", strict=True) == 1.0
    assert parsenumber(str(sys.maxint + 1), strict=True) == sys.maxint + 1
    assert parsenumber("3+4j", strict=True) == 3 + 4j
    try:
        parsenumber("aaa", strict=True)
    except:
        pass  # expected
    else:
        assert False, "expected exception"
    try:
        parsenumber(None, strict=True)
    except:
        pass  # expected
    else:
        assert False, "expected exception"