def test_generic_with_one_arg(self): g = Generic('List', [self.int]) self.assertEqual(g.typename, 'List') self.assertEqual(str(g.args), '(Instance(int),)') self.assertEqual(str(g), 'List[int]') self.assertEqual(repr(g), 'List[int]') self.assertEqual(g, Generic('List', [self.int])) self.assertNotEqual(g, Generic('Set', [self.int])) self.assertNotEqual(g, Generic('List', [self.float])) self.assertNotEqual(g, self.int)
def test_generic_with_two_args(self): g = Generic('Dict', (self.int, self.float)) self.assertEqual(g.typename, 'Dict') self.assertEqual(str(g), 'Dict[int, float]')
def list_(x): return Generic('List', [x])