def test_annotation_argument(self): annotation = ast.Annotation('SomeAnnotation', 'value') arg = ast.Argument('Argument', ast.Argument.DIRECTION_IN, 's', { 'SomeAnnotation': annotation, }) method = ast.Method('AMethod', [arg]) ast.Interface('Some.Interface', { 'AMethod': method, }) self.assertEqual( annotation.format_name(), 'SomeAnnotation of ‘0 (‘Argument’)' ' of method ‘Some.Interface.AMethod’’')
def test_argument(self): annotation = ast.Annotation('SomeAnnotation', 'value') self.assertEqual(annotation.parent, None) arg = ast.Argument('SomeArgument', ast.Argument.DIRECTION_IN, 's', { 'SomeAnnotation': annotation, }) self.assertEqual(arg.parent, None) self.assertEqual(arg.index, -1) self.assertEqual(annotation.parent, arg) method = ast.Method('AMethod', [arg]) self.assertEqual(arg.parent, method) self.assertEqual(arg.index, 0)
def test_argument_unnamed_unparented(self): arg = ast.Argument(None, ast.Argument.DIRECTION_IN, 's') self.assertEqual(arg.format_name(), 'unnamed')
def test_argument_unnamed(self): arg = ast.Argument(None, ast.Argument.DIRECTION_IN, 's') ast.Method('ParentMethod', [arg]) self.assertEqual(arg.format_name(), '0 of method ‘ParentMethod’')
def test_argument_unparented(self): arg = ast.Argument('self', ast.Argument.DIRECTION_IN, 's') self.assertEqual(arg.format_name(), '‘self’')
def test_argument(self): arg = ast.Argument('self', ast.Argument.DIRECTION_IN, 's') ast.Method('ParentMethod', [arg]) self.assertEqual(arg.format_name(), '0 (‘self’) of method ‘ParentMethod’')
def test_argument(self): arg = ast.Argument('self', ast.Argument.DIRECTION_IN, 's') self.assertIsInstance(arg.type, TypeSignature) self.assertEqual(str(arg.type), 's')