def test_invalid_type(self): mt = multitype(Bool.partial(true=('yes', ), false=('no', )), Float, Tuple.partial(options=('a', 'b', 'c'))) with self.assert_raises( ValueError, 'Not a boolean; Not a number; Invalid option: hi'): mt('hi') with self.assert_raises( ValueError, 'Not a boolean; Not a number; Invalid option: d'): mt('a', 'b', 'd')
def test_equality(self): B = Bool.partial(true=('x', 'y', 'z'), false=(1, 2, 3)) self.assertEqual(B('x'), B('y')) self.assertEqual(B('y'), B('z')) self.assertEqual(B('z'), True) self.assertEqual(B(1), B(2)) self.assertEqual(B(2), B(3)) self.assertEqual(B(3), False) self.assertNotEqual(B('x'), None) self.assertNotEqual(B(2), None)