Esempio n. 1
0
 def test_enums(self):
     ty1 = types.EnumMember(Color, types.int32)
     self.check_pickling(ty1)
     ty2 = types.EnumMember(Shake, types.int64)
     self.check_pickling(ty2)
     ty3 = types.IntEnumMember(Shape, types.int64)
     self.check_pickling(ty3)
Esempio n. 2
0
    def test_enum(self):
        tp_red = typeof(Color.red)
        self.assertEqual(tp_red, types.EnumMember(Color, types.intp))
        self.assertEqual(tp_red, typeof(Color.blue))
        tp_choc = typeof(Shake.chocolate)
        self.assertEqual(tp_choc, types.EnumMember(Shake, types.intp))
        self.assertEqual(tp_choc, typeof(Shake.mint))
        self.assertNotEqual(tp_choc, tp_red)
        tp_404 = typeof(RequestError.not_found)
        self.assertEqual(tp_404, types.IntEnumMember(RequestError, types.intp))
        self.assertEqual(tp_404, typeof(RequestError.internal_error))

        with self.assertRaises(ValueError) as raises:
            typeof(HeterogenousEnum.red)
        self.assertEqual(str(raises.exception),
                         "Cannot type heterogenous enum: got value types complex128, float64")