Exemple #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)
Exemple #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
 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
 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
Exemple #5
0
 def test_create(self):
     val = Int8(123)
     assert val.value() == 123
Exemple #6
0
 def test_encode(self):
     val = Int8(123)
     assert val.encode() == b'{'
Exemple #7
0
 def test_decode_remainder(self):
     (val, rest) = Int8.decode(b'{abc')
     assert val.value() == 123
     assert rest == b'abc'
Exemple #8
0
 def test_decode(self):
     (val, rest) = Int8.decode(b'{')
     assert isinstance(val, Int8)
     assert val.value() == 123
     assert rest == b''
 def test_str(self):
     val = Int8(123)
     assert str(val) == "123 (int8)"
     assert repr(val) == "<Int8 123>"
 def test_bool(self):
     val = Int8(0)
     val2 = Int8(1)
     assert not val
     assert val2
Exemple #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
 def test_gt(self):
     val = Int8(91)
     val2 = Int8(123)
     assert val2 > val
     assert val2 > 91
     assert 123 > val
 def test_lt(self):
     val = Int8(91)
     val2 = Int8(123)
     assert val < val2
     assert val < 123
     assert 91 < val2
 def test_ne(self):
     val = Int8(123)
     val2 = Int8(91)
     assert val != val2
     assert val != 91
     assert 91 != val
 def test_eq(self):
     val = Int8(123)
     val2 = Int8(123)
     assert val == val2
     assert val == 123
     assert 123 == val
Exemple #16
0
 def test_contains_null_array(self):
     i1 = Int8(123)
     val = Array(None, schema='int8')
     assert i1 not in val
 def test_get_other_value(self):
     val = _get_other_value(Int8(42))
     assert isinstance(val, six.integer_types)
     assert val == 42