Exemplo n.º 1
0
 def test_number_long2(self, space):
     w_l = PyNumber_Long(space, space.wraplong(123L))
     assert PyLong_CheckExact(space, w_l)
     w_l = PyNumber_Long(space, space.wrap(2 << 65))
     assert PyLong_CheckExact(space, w_l)
     w_l = PyNumber_Long(space, space.wrap(42.3))
     assert PyLong_CheckExact(space, w_l)
     w_l = PyNumber_Long(space, space.wrap("42"))
     assert PyLong_CheckExact(space, w_l)
Exemplo n.º 2
0
    def test_type_check(self, space, api):
        w_l = space.wrap(sys.maxint + 1)
        assert PyLong_Check(space, w_l)
        assert PyLong_CheckExact(space, w_l)

        w_i = space.wrap(sys.maxint)
        assert not PyLong_Check(space, w_i)
        assert not PyLong_CheckExact(space, w_i)

        L = space.appexec([], """():
            class L(long):
                pass
            return L
        """)
        l = space.call_function(L)
        assert PyLong_Check(space, l)
        assert not PyLong_CheckExact(space, l)
Exemplo n.º 3
0
 def test_number_index(self, space):
     w_l = PyNumber_Index(space, space.wraplong(123L))
     assert PyLong_CheckExact(space, w_l)
     with pytest.raises(OperationError):
         PyNumber_Index(space, space.wrap(42.3))
Exemplo n.º 4
0
 def test_number_long(self, space):
     w_l = PyNumber_Long(space, space.wrap(123))
     assert PyLong_CheckExact(space, w_l)
     w_l = PyNumber_Long(space, space.wrap("123"))
     assert PyLong_CheckExact(space, w_l)