예제 #1
0
 def _validate(self):
     if self._value:
         self._value = True
         self._underlying_value = Int8(1)
     else:
         self._value = False
         self._underlying_value = Int8(0)
예제 #2
0
 def test_contains(self):
     i1 = Int8(123)
     i2 = Int8(91)
     i3 = Int8(32)
     val = Array([i1, i2], schema='int8', skip_validation=True)
     assert i1 in val
     assert i2 in val
     assert i3 not in val
예제 #3
0
 def test_ge(self):
     val = Int8(91)
     val2 = Int8(123)
     val3 = Int8(91)
     assert val2 >= val
     assert val3 >= val
     assert val2 >= 91
     assert val >= 91
     assert 123 >= val
     assert 91 >= val
예제 #4
0
 def test_le(self):
     val = Int8(91)
     val2 = Int8(123)
     val3 = Int8(91)
     assert val <= val2
     assert val <= val3
     assert val <= 123
     assert val2 <= 123
     assert 91 <= val2
     assert 91 <= val
예제 #5
0
 def test_create(self):
     val = Int8(123)
     assert val.value() == 123
예제 #6
0
 def test_encode(self):
     val = Int8(123)
     assert val.encode() == b'{'
예제 #7
0
 def test_decode_remainder(self):
     (val, rest) = Int8.decode(b'{abc')
     assert val.value() == 123
     assert rest == b'abc'
예제 #8
0
 def test_decode(self):
     (val, rest) = Int8.decode(b'{')
     assert isinstance(val, Int8)
     assert val.value() == 123
     assert rest == b''
예제 #9
0
 def test_str(self):
     val = Int8(123)
     assert str(val) == "123 (int8)"
     assert repr(val) == "<Int8 123>"
예제 #10
0
 def test_bool(self):
     val = Int8(0)
     val2 = Int8(1)
     assert not val
     assert val2
예제 #11
0
 def decode(cls, byte_array, schema=None):
     underlying_value, remaining_bytes = Int8.decode(byte_array)
     return cls(underlying_value.value() == 1,
                schema=cls._type), remaining_bytes
예제 #12
0
 def test_gt(self):
     val = Int8(91)
     val2 = Int8(123)
     assert val2 > val
     assert val2 > 91
     assert 123 > val
예제 #13
0
 def test_lt(self):
     val = Int8(91)
     val2 = Int8(123)
     assert val < val2
     assert val < 123
     assert 91 < val2
예제 #14
0
 def test_ne(self):
     val = Int8(123)
     val2 = Int8(91)
     assert val != val2
     assert val != 91
     assert 91 != val
예제 #15
0
 def test_eq(self):
     val = Int8(123)
     val2 = Int8(123)
     assert val == val2
     assert val == 123
     assert 123 == val
예제 #16
0
 def test_contains_null_array(self):
     i1 = Int8(123)
     val = Array(None, schema='int8')
     assert i1 not in val
예제 #17
0
 def test_get_other_value(self):
     val = _get_other_value(Int8(42))
     assert isinstance(val, six.integer_types)
     assert val == 42