Esempio n. 1
0
    def test_valid_value_behaves_like_subclass_instance(self):
        mt = multitype(Float.partial(min=10), String)
        x = mt(15)
        self.assertEqual(x, 15.0)
        self.assertEqual(x + 5, 20.0)
        with self.assert_raises(TypeError):
            x + '!'

        x = mt('hello')
        self.assertEqual(x, 'hello')
        self.assertEqual(x + '!', 'hello!')
        with self.assert_raises(TypeError):
            x + 5
Esempio n. 2
0
 def test_classname(self):
     mt = multitype(Bool, Float.partial(max=100), String)
     self.assertEqual(mt.__name__, 'BoolOrFloatOrString')