Exemplo n.º 1
0
 def __from_str__(self):
     if utils.RepresentsInt(self.size):
         self.size = int(self.size)
     else:
         # ToDo: Handle Error
         pass
Exemplo n.º 2
0
def test_utils_01_represents_int():
    assert utils.RepresentsInt("10")
    assert utils.RepresentsInt("0")
    assert utils.RepresentsInt("-10")
    assert utils.RepresentsInt("1123")
    assert utils.RepresentsInt("99999")
    assert utils.RepresentsInt("-99999")
    assert utils.RepresentsInt("+99999")
    assert utils.RepresentsInt("123456789")

    assert utils.RepresentsInt(10)
    assert utils.RepresentsInt(0)
    assert utils.RepresentsInt(-10)
    assert utils.RepresentsInt(1123)
    assert utils.RepresentsInt(99999)
    assert utils.RepresentsInt(-99999)
    assert utils.RepresentsInt(+99999)
    assert utils.RepresentsInt(123456789)

    assert not utils.RepresentsInt("10.0")
    assert not utils.RepresentsInt("0.0")
    assert not utils.RepresentsInt("-10.0")
    assert not utils.RepresentsInt("1.")
    assert not utils.RepresentsInt("asd")
    assert not utils.RepresentsInt("number")
    assert not utils.RepresentsInt("3+6j")
    assert not utils.RepresentsInt("-")
    assert not utils.RepresentsInt("+")

    assert not utils.RepresentsInt(10.0)
    assert not utils.RepresentsInt(0.0)
    assert not utils.RepresentsInt(-10.0)
    assert not utils.RepresentsInt(1.0)
    assert not utils.RepresentsInt(3 + 6j)
    assert not utils.RepresentsInt([])
    assert not utils.RepresentsInt({})
    assert not utils.RepresentsInt(())