diff options
Diffstat (limited to 'python/testData')
116 files changed, 943 insertions, 22 deletions
diff --git a/python/testData/formatter/alignListComprehensionInDict.py b/python/testData/formatter/alignListComprehensionInDict.py new file mode 100644 index 000000000000..7b742792fc75 --- /dev/null +++ b/python/testData/formatter/alignListComprehensionInDict.py @@ -0,0 +1,5 @@ +def foo(): + return {field.key: field for key, field in inspect.getmembers(instance) + if isinstance(field, QueryableAttribute) + and isinstance(field.property, ColumnProperty) + or field.foreign_keys}
\ No newline at end of file diff --git a/python/testData/formatter/alignListComprehensionInDict_after.py b/python/testData/formatter/alignListComprehensionInDict_after.py new file mode 100644 index 000000000000..bcb4c2205c12 --- /dev/null +++ b/python/testData/formatter/alignListComprehensionInDict_after.py @@ -0,0 +1,5 @@ +def foo(): + return {field.key: field for key, field in inspect.getmembers(instance) + if isinstance(field, QueryableAttribute) + and isinstance(field.property, ColumnProperty) + or field.foreign_keys}
\ No newline at end of file diff --git a/python/testData/formatter/twoLinesBetweenTopLevelDeclarationsWithComment.py b/python/testData/formatter/twoLinesBetweenTopLevelDeclarationsWithComment.py index a0f52904114e..c9082539ab46 100644 --- a/python/testData/formatter/twoLinesBetweenTopLevelDeclarationsWithComment.py +++ b/python/testData/formatter/twoLinesBetweenTopLevelDeclarationsWithComment.py @@ -1,7 +1,7 @@ class A(object): pass -#comment +# comment def one(): pass @@ -9,10 +9,10 @@ def one(): def two(): pass -#comment +# comment class B(object): pass -#comment +# comment class C(object): pass
\ No newline at end of file diff --git a/python/testData/formatter/twoLinesBetweenTopLevelDeclarationsWithComment_after.py b/python/testData/formatter/twoLinesBetweenTopLevelDeclarationsWithComment_after.py index d582036d8654..ba0e69717738 100644 --- a/python/testData/formatter/twoLinesBetweenTopLevelDeclarationsWithComment_after.py +++ b/python/testData/formatter/twoLinesBetweenTopLevelDeclarationsWithComment_after.py @@ -2,7 +2,7 @@ class A(object): pass -#comment +# comment def one(): pass @@ -12,11 +12,11 @@ def two(): pass -#comment +# comment class B(object): pass -#comment +# comment class C(object): pass
\ No newline at end of file diff --git a/python/testData/inspections/PyTypeCheckerInspection/DefaultTupleParameter.py b/python/testData/inspections/PyTypeCheckerInspection/DefaultTupleParameter.py new file mode 100644 index 000000000000..0e082e8ad506 --- /dev/null +++ b/python/testData/inspections/PyTypeCheckerInspection/DefaultTupleParameter.py @@ -0,0 +1,5 @@ +def f(x=(), y=('foo', 'bar')): + pass + + +f([1, 2, 3], ['foo']) diff --git a/python/testData/psi/BadDecoratorNotMethod.py b/python/testData/psi/BadDecoratorNotMethod.py new file mode 100644 index 000000000000..1e3b5e6e8ff3 --- /dev/null +++ b/python/testData/psi/BadDecoratorNotMethod.py @@ -0,0 +1,4 @@ +class Foo(object): + @staticmethod + def bad_method(): #test + pass
\ No newline at end of file diff --git a/python/testData/psi/BadDecoratorNotMethod.txt b/python/testData/psi/BadDecoratorNotMethod.txt new file mode 100644 index 000000000000..b2269d3ff516 --- /dev/null +++ b/python/testData/psi/BadDecoratorNotMethod.txt @@ -0,0 +1,44 @@ +PyFile:BadDecoratorNotMethod.py + PyClass: Foo + PsiElement(Py:CLASS_KEYWORD)('class') + PsiWhiteSpace(' ') + PsiElement(Py:IDENTIFIER)('Foo') + PyArgumentList + PsiElement(Py:LPAR)('(') + PyReferenceExpression: object + PsiElement(Py:IDENTIFIER)('object') + PsiElement(Py:RPAR)(')') + PsiElement(Py:COLON)(':') + PsiWhiteSpace('\n ') + PyStatementList + PyFunction('null') + PyDecoratorList + PyDecorator: @staticmethod + PsiElement(Py:AT)('@') + PyReferenceExpression: staticmethod + PsiElement(Py:IDENTIFIER)('staticmethod') + PyArgumentList + <empty list> + PsiErrorElement:'@' or 'def' expected + <empty list> + PsiWhiteSpace('\n ') + PyParameterList + <empty list> + PyStatementList + <empty list> + PsiErrorElement:Unexpected indent + <empty list> + PyFunction('bad_method') + PsiElement(Py:DEF_KEYWORD)('def') + PsiWhiteSpace(' ') + PsiElement(Py:IDENTIFIER)('bad_method') + PyParameterList + PsiElement(Py:LPAR)('(') + PsiElement(Py:RPAR)(')') + PsiElement(Py:COLON)(':') + PsiWhiteSpace(' ') + PsiComment(Py:END_OF_LINE_COMMENT)('#test') + PsiWhiteSpace('\n ') + PyStatementList + PyPassStatement + PsiElement(Py:PASS_KEYWORD)('pass')
\ No newline at end of file diff --git a/python/testData/refactoring/argumentList/addKeyArgument/addArgumentFile.after.py b/python/testData/refactoring/argumentList/addKeyArgument/addArgumentFile.after.py new file mode 100644 index 000000000000..7a9fbe968399 --- /dev/null +++ b/python/testData/refactoring/argumentList/addKeyArgument/addArgumentFile.after.py @@ -0,0 +1,32 @@ +from stub import * +import stub + + +class MyOldClass(metaclass=ABCMeta): + pass + + +class MyNewClass(object,metaclass=ABCMeta): + pass + + +class MyNewClass_2(object, datetime,metaclass=ABCMeta): + pass + +class NewClass_3(stub.object,metaclass=ABCMeta): + pass + +class NewClass_4(stub.object, stub.datetime,metaclass=ABCMeta): + pass + +class NewClass_5(stub.datetime, foo=stub.object,metaclass=ABCMeta): + pass + + +spam = "new_param" + +my_function(new_param=spam) +my_function_1("some_param",new_param=spam) +my_function_2(named_param="ham",new_param=spam) +my_function_3("some_param", "some_param_2", named_param="ham",new_param=spam) +my_function_4("some_param", "some_param_2", named_param=stub.object, named_param_2="eggs",new_param=spam)
\ No newline at end of file diff --git a/python/testData/refactoring/argumentList/addKeyArgument/addArgumentFile.py b/python/testData/refactoring/argumentList/addKeyArgument/addArgumentFile.py new file mode 100644 index 000000000000..32b4fda7409e --- /dev/null +++ b/python/testData/refactoring/argumentList/addKeyArgument/addArgumentFile.py @@ -0,0 +1,32 @@ +from stub import * +import stub + + +class MyOldClass(): + pass + + +class MyNewClass(object): + pass + + +class MyNewClass_2(object, datetime): + pass + +class NewClass_3(stub.object): + pass + +class NewClass_4(stub.object, stub.datetime): + pass + +class NewClass_5(stub.datetime, foo=stub.object): + pass + + +spam = "new_param" + +my_function() +my_function_1("some_param") +my_function_2(named_param="ham") +my_function_3("some_param", "some_param_2", named_param="ham") +my_function_4("some_param", "some_param_2", named_param=stub.object, named_param_2="eggs")
\ No newline at end of file diff --git a/python/testData/refactoring/argumentList/addKeyArgument/stub.py b/python/testData/refactoring/argumentList/addKeyArgument/stub.py new file mode 100644 index 000000000000..9227a3542e01 --- /dev/null +++ b/python/testData/refactoring/argumentList/addKeyArgument/stub.py @@ -0,0 +1,13 @@ +class object: pass + +class datetime: pass + + +class ABCMeta: pass + + +def my_function(new_param="spam"): pass +def my_function_1(first_param,some_param, new_param="spam"): pass +def my_function_2(first_param,named_param="ham", new_param="spam"): pass +def my_function_3(first_param,some_param, some_param_2, named_param="ham", new_param="spam"): pass +def my_function_4(first_param,some_param, some_param_2, named_param="ham", named_param_2="eggs", new_param="spam"): pass
\ No newline at end of file diff --git a/python/testData/refactoring/argumentList/addParam/addArgumentFile.after.py b/python/testData/refactoring/argumentList/addParam/addArgumentFile.after.py new file mode 100644 index 000000000000..97c18fd7f85b --- /dev/null +++ b/python/testData/refactoring/argumentList/addParam/addArgumentFile.after.py @@ -0,0 +1,27 @@ +from stub import * +import stub + + +class MyOldClass(SuperClass): + pass + + +class MyNewClass(object,SuperClass): + pass + + +class MyNewClass_2(object, datetime,SuperClass): + pass + +class NewClass_3(stub.object,SuperClass): + pass + +class NewClass_4(stub.object, stub.datetime,SuperClass): + pass + +new_param = "ogg" + +my_function(new_param,some_param="spam") +my_function(new_param) +my_function_2("some_param",new_param) +my_function_3(new_param,some_param="spam",some_another_param=stub.object)
\ No newline at end of file diff --git a/python/testData/refactoring/argumentList/addParam/addArgumentFile.py b/python/testData/refactoring/argumentList/addParam/addArgumentFile.py new file mode 100644 index 000000000000..32d0235e1266 --- /dev/null +++ b/python/testData/refactoring/argumentList/addParam/addArgumentFile.py @@ -0,0 +1,27 @@ +from stub import * +import stub + + +class MyOldClass(): + pass + + +class MyNewClass(object): + pass + + +class MyNewClass_2(object, datetime): + pass + +class NewClass_3(stub.object): + pass + +class NewClass_4(stub.object, stub.datetime): + pass + +new_param = "ogg" + +my_function(some_param="spam") +my_function() +my_function_2("some_param") +my_function_3(some_param="spam",some_another_param=stub.object)
\ No newline at end of file diff --git a/python/testData/refactoring/argumentList/addParam/stub.py b/python/testData/refactoring/argumentList/addParam/stub.py new file mode 100644 index 000000000000..b98bdb0d1fca --- /dev/null +++ b/python/testData/refactoring/argumentList/addParam/stub.py @@ -0,0 +1,13 @@ +class object: pass + +class datetime: pass + + +class ABCMeta: pass + +class SuperClass: pass + + +def my_function(new_param,some_param="spam"): pass +def my_function_2(new_param,some_param): pass +def my_function_3(new_param,some_param="spam",some_another_param="eggs"): pass diff --git a/python/testData/refactoring/extractmethod/Comment2.after.py b/python/testData/refactoring/extractmethod/Comment2.after.py index 5e5fdc3c6a8c..c5cc3a7ff224 100644 --- a/python/testData/refactoring/extractmethod/Comment2.after.py +++ b/python/testData/refactoring/extractmethod/Comment2.after.py @@ -1,6 +1,6 @@ class Foo(): def baz(): - tmp = "!" #try to extract this assignmet, either with or without this comment + tmp = "!" # try to extract this assignment, either with or without this comment baz() diff --git a/python/testData/refactoring/extractmethod/Comment2.before.py b/python/testData/refactoring/extractmethod/Comment2.before.py index d43386aff93c..23ba13de61f7 100644 --- a/python/testData/refactoring/extractmethod/Comment2.before.py +++ b/python/testData/refactoring/extractmethod/Comment2.before.py @@ -1,5 +1,5 @@ class Foo(): - <selection>tmp = "!" #try to extract this assignmet, either with or without this comment</selection> + <selection>tmp = "!" #try to extract this assignment, either with or without this comment</selection> def bar(self): pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractmethod/ElseBody.after.py b/python/testData/refactoring/extractmethod/ElseBody.after.py index 57b5fa011715..24e387dd3633 100644 --- a/python/testData/refactoring/extractmethod/ElseBody.after.py +++ b/python/testData/refactoring/extractmethod/ElseBody.after.py @@ -1,5 +1,5 @@ def baz(f_new): - length = len(f_new.readlines()) #<---extract something from here + length = len(f_new.readlines()) # <---extract something from here print("hi from else") diff --git a/python/testData/refactoring/extractsuperclass/importMultiFile/dest_module.after.py b/python/testData/refactoring/extractsuperclass/importMultiFile/dest_module.after.py new file mode 100644 index 000000000000..eba5f32d8456 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importMultiFile/dest_module.after.py @@ -0,0 +1,9 @@ +import shared_module +from shared_module import module_function as my_function, ModuleClass + + +class NewParent(object): + def do_useful_stuff(self): + i = shared_module.MODULE_CONTANT + my_function() + ModuleClass()
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/importMultiFile/dest_module.py b/python/testData/refactoring/extractsuperclass/importMultiFile/dest_module.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importMultiFile/dest_module.py diff --git a/python/testData/refactoring/extractsuperclass/importMultiFile/shared_module.py b/python/testData/refactoring/extractsuperclass/importMultiFile/shared_module.py new file mode 100644 index 000000000000..13fe833465ef --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importMultiFile/shared_module.py @@ -0,0 +1,9 @@ +MODULE_CONTANT = 42 + + +def module_function(): + pass + + +class ModuleClass(object): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/importMultiFile/source_module.after.py b/python/testData/refactoring/extractsuperclass/importMultiFile/source_module.after.py new file mode 100644 index 000000000000..b9d711783970 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importMultiFile/source_module.after.py @@ -0,0 +1,5 @@ +from dest_module import NewParent + + +class MyClass(NewParent): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/importMultiFile/source_module.py b/python/testData/refactoring/extractsuperclass/importMultiFile/source_module.py new file mode 100644 index 000000000000..aa10bca28fea --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importMultiFile/source_module.py @@ -0,0 +1,9 @@ +import shared_module +from shared_module import module_function as my_function +from shared_module import ModuleClass + +class MyClass(object): + def do_useful_stuff(self): + i = shared_module.MODULE_CONTANT + my_function() + ModuleClass()
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/importNotBroken.after.py b/python/testData/refactoring/extractsuperclass/importNotBroken.after.py new file mode 100644 index 000000000000..897c62a71cfc --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importNotBroken.after.py @@ -0,0 +1,9 @@ +from shared import SharedClass + + +class DestClass(SharedClass): + pass + + +class Source(DestClass): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/importNotBroken.before.py b/python/testData/refactoring/extractsuperclass/importNotBroken.before.py new file mode 100644 index 000000000000..82d6d5c04c20 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importNotBroken.before.py @@ -0,0 +1,5 @@ +from shared import SharedClass + + +class Source(SharedClass): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/dest_module.after.py b/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/dest_module.after.py new file mode 100644 index 000000000000..6189ad4fc76b --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/dest_module.after.py @@ -0,0 +1,5 @@ +from shared_module import SharedClass + + +class NewParent(SharedClass): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/dest_module.py b/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/dest_module.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/dest_module.py diff --git a/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/shared_module.py b/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/shared_module.py new file mode 100644 index 000000000000..da81c49673f4 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/shared_module.py @@ -0,0 +1 @@ +class SharedClass(object): pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/source_module.after.py b/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/source_module.after.py new file mode 100644 index 000000000000..b9d711783970 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/source_module.after.py @@ -0,0 +1,5 @@ +from dest_module import NewParent + + +class MyClass(NewParent): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/source_module.py b/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/source_module.py new file mode 100644 index 000000000000..1824aec09d61 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/importNotBrokenManyFiles/source_module.py @@ -0,0 +1,4 @@ +from shared_module import SharedClass + +class MyClass(SharedClass): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/instanceNotDeclaredInInit.after.py b/python/testData/refactoring/extractsuperclass/instanceNotDeclaredInInit.after.py new file mode 100644 index 000000000000..ef3511dc8c66 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/instanceNotDeclaredInInit.after.py @@ -0,0 +1,8 @@ +class Parent(object): + def __init__(self): + self.eggs = 12 + + +class Child(Parent): + def foo(self): + self.eggs = 12 diff --git a/python/testData/refactoring/extractsuperclass/instanceNotDeclaredInInit.before.py b/python/testData/refactoring/extractsuperclass/instanceNotDeclaredInInit.before.py new file mode 100644 index 000000000000..9c5594a80067 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/instanceNotDeclaredInInit.before.py @@ -0,0 +1,3 @@ +class Child(object): + def foo(self): + self.eggs = 12 diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/abc.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/abc.py new file mode 100644 index 000000000000..ef4f2f69e838 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/abc.py @@ -0,0 +1,8 @@ +# Stubs + +class ABCMeta: + pass + + +def abstractmethod(foo): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/dest_module.after.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/dest_module.after.py new file mode 100644 index 000000000000..bbf726c919ae --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/dest_module.after.py @@ -0,0 +1,13 @@ +from abc import abstractmethod +from abc import ABCMeta + + +class NewParent(object): + __metaclass__ = ABCMeta + + @abstractmethod + def foo_method(self): + """ + Foo + """ + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/dest_module.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/dest_module.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/dest_module.py diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/shared_module.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/shared_module.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/shared_module.py diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/source_module.after.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/source_module.after.py new file mode 100644 index 000000000000..6e71752a511d --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/source_module.after.py @@ -0,0 +1,9 @@ +from dest_module import NewParent + + +class MyClass(NewParent): + def foo_method(self): + """ + Foo + """ + spam = "eggs"
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/source_module.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/source_module.py new file mode 100644 index 000000000000..f4a7c42a7df4 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstract/source_module.py @@ -0,0 +1,6 @@ +class MyClass(object): + def foo_method(self): + """ + Foo + """ + spam = "eggs"
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/abc.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/abc.py new file mode 100644 index 000000000000..ef4f2f69e838 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/abc.py @@ -0,0 +1,8 @@ +# Stubs + +class ABCMeta: + pass + + +def abstractmethod(foo): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/dest_module.after.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/dest_module.after.py new file mode 100644 index 000000000000..ddce4a86100f --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/dest_module.after.py @@ -0,0 +1,13 @@ +from abc import ABCMeta +from abc import abstractmethod + + +ABCMeta() +abstractmethod() + + +class NewParent(metaclass=ABCMeta): + @classmethod + @abstractmethod + def foo_method(cls): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/dest_module.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/dest_module.py new file mode 100644 index 000000000000..81549d3c4c0f --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/dest_module.py @@ -0,0 +1,6 @@ +from abc import ABCMeta +from abc import abstractmethod + + +ABCMeta() +abstractmethod()
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/shared_module.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/shared_module.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/shared_module.py diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/source_module.after.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/source_module.after.py new file mode 100644 index 000000000000..02c129fc8082 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/source_module.after.py @@ -0,0 +1,7 @@ +from dest_module import NewParent + + +class MyClass(NewParent): + @classmethod + def foo_method(cls): + spam = "eggs"
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/source_module.py b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/source_module.py new file mode 100644 index 000000000000..b197c5fc2bfa --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveAndMakeAbstractImportExistsPy3/source_module.py @@ -0,0 +1,4 @@ +class MyClass(): + @classmethod + def foo_method(cls): + spam = "eggs"
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveExtends/dest_module.after.py b/python/testData/refactoring/extractsuperclass/moveExtends/dest_module.after.py new file mode 100644 index 000000000000..1171abf73b10 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveExtends/dest_module.after.py @@ -0,0 +1,5 @@ +from shared_module import TheParentOfItAll + + +class NewParent(TheParentOfItAll): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveExtends/dest_module.py b/python/testData/refactoring/extractsuperclass/moveExtends/dest_module.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveExtends/dest_module.py diff --git a/python/testData/refactoring/extractsuperclass/moveExtends/shared_module.py b/python/testData/refactoring/extractsuperclass/moveExtends/shared_module.py new file mode 100644 index 000000000000..fd3d3fc7bf88 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveExtends/shared_module.py @@ -0,0 +1,2 @@ +class TheParentOfItAll(object): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveExtends/source_module.after.py b/python/testData/refactoring/extractsuperclass/moveExtends/source_module.after.py new file mode 100644 index 000000000000..b9d711783970 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveExtends/source_module.after.py @@ -0,0 +1,5 @@ +from dest_module import NewParent + + +class MyClass(NewParent): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveExtends/source_module.py b/python/testData/refactoring/extractsuperclass/moveExtends/source_module.py new file mode 100644 index 000000000000..87c753aa0698 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveExtends/source_module.py @@ -0,0 +1,4 @@ +import shared_module + +class MyClass(shared_module.TheParentOfItAll): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/dest_module.after.py b/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/dest_module.after.py new file mode 100644 index 000000000000..1171abf73b10 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/dest_module.after.py @@ -0,0 +1,5 @@ +from shared_module import TheParentOfItAll + + +class NewParent(TheParentOfItAll): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/dest_module.py b/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/dest_module.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/dest_module.py diff --git a/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/shared_module.py b/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/shared_module.py new file mode 100644 index 000000000000..fd3d3fc7bf88 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/shared_module.py @@ -0,0 +1,2 @@ +class TheParentOfItAll(object): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/source_module.after.py b/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/source_module.after.py new file mode 100644 index 000000000000..b9d711783970 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/source_module.after.py @@ -0,0 +1,5 @@ +from dest_module import NewParent + + +class MyClass(NewParent): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/source_module.py b/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/source_module.py new file mode 100644 index 000000000000..c2ca97497a33 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveExtendsCheckReference/source_module.py @@ -0,0 +1,4 @@ +from shared_module import TheParentOfItAll + +class MyClass(TheParentOfItAll): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveFields.after.py b/python/testData/refactoring/extractsuperclass/moveFields.after.py new file mode 100644 index 000000000000..043e4d34a5ff --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveFields.after.py @@ -0,0 +1,10 @@ +class ToClass(object): + CLASS_FIELD = 42 + + def __init__(self): + self.instance_field = 100500 + + +class FromClass(ToClass): + def __init__(self): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/moveFields.before.py b/python/testData/refactoring/extractsuperclass/moveFields.before.py new file mode 100644 index 000000000000..54a167fac430 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/moveFields.before.py @@ -0,0 +1,4 @@ +class FromClass(object): + CLASS_FIELD = 42 + def __init__(self): + self.instance_field = 100500 diff --git a/python/testData/refactoring/extractsuperclass/presenter/file.py b/python/testData/refactoring/extractsuperclass/presenter/file.py new file mode 100644 index 000000000000..9e6af14bf862 --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/presenter/file.py @@ -0,0 +1,20 @@ +from datetime import date +class Child(object, date): + CLASS_VAR = "spam" + + def eggs(self): # May be abstract + pass + + def __init__(self): + super(Child, self).__init__() + self.artur = "king" + +class StaticOnly(object): + @staticmethod + def static_method(): # May be abstract in case of Py3 + pass + + +class OldClass(): + def foo(self): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/shared.py b/python/testData/refactoring/extractsuperclass/shared.py new file mode 100644 index 000000000000..71f03ab781fc --- /dev/null +++ b/python/testData/refactoring/extractsuperclass/shared.py @@ -0,0 +1 @@ +class SharedClass: pass
\ No newline at end of file diff --git a/python/testData/refactoring/extractsuperclass/withImport.after.py b/python/testData/refactoring/extractsuperclass/withImport.after.py index ccd508bbebd7..86018635c236 100644 --- a/python/testData/refactoring/extractsuperclass/withImport.after.py +++ b/python/testData/refactoring/extractsuperclass/withImport.after.py @@ -1,4 +1,3 @@ -import os from refactoring.extractsuperclass import Suppa diff --git a/python/testData/refactoring/pullup/abstractMethodHasMeta/Class.after.py b/python/testData/refactoring/pullup/abstractMethodHasMeta/Class.after.py new file mode 100644 index 000000000000..e85e0f23eb4d --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodHasMeta/Class.after.py @@ -0,0 +1,4 @@ +from SuperClass import Parent +class Child(Parent): + def my_method(self, foo): + bar = foo
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodHasMeta/Class.py b/python/testData/refactoring/pullup/abstractMethodHasMeta/Class.py new file mode 100644 index 000000000000..e85e0f23eb4d --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodHasMeta/Class.py @@ -0,0 +1,4 @@ +from SuperClass import Parent +class Child(Parent): + def my_method(self, foo): + bar = foo
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodHasMeta/SuperClass.after.py b/python/testData/refactoring/pullup/abstractMethodHasMeta/SuperClass.after.py new file mode 100644 index 000000000000..b0004eb378e7 --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodHasMeta/SuperClass.after.py @@ -0,0 +1,13 @@ +from abc import ABCMeta, abstractmethod + + +class Parent(object): + __metaclass__ = ABCMeta + + @abstractmethod + def my_method2(self): + pass + + @abstractmethod + def my_method(self, foo): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodHasMeta/SuperClass.py b/python/testData/refactoring/pullup/abstractMethodHasMeta/SuperClass.py new file mode 100644 index 000000000000..14d85de078a3 --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodHasMeta/SuperClass.py @@ -0,0 +1,9 @@ +from abc import ABCMeta, abstractmethod + + +class Parent(object): + __metaclass__ = ABCMeta + + @abstractmethod + def my_method2(self): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodHasMeta/abc.py b/python/testData/refactoring/pullup/abstractMethodHasMeta/abc.py new file mode 100644 index 000000000000..ef4f2f69e838 --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodHasMeta/abc.py @@ -0,0 +1,8 @@ +# Stubs + +class ABCMeta: + pass + + +def abstractmethod(foo): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/Class.after.py b/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/Class.after.py new file mode 100644 index 000000000000..69998c4dcf7e --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/Class.after.py @@ -0,0 +1,7 @@ +from SuperClass import Parent +class Child(Parent): + def my_method(self, foo): + bar = foo + + def my_method_2(self, foo): + bar = foo
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/Class.py b/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/Class.py new file mode 100644 index 000000000000..69998c4dcf7e --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/Class.py @@ -0,0 +1,7 @@ +from SuperClass import Parent +class Child(Parent): + def my_method(self, foo): + bar = foo + + def my_method_2(self, foo): + bar = foo
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/SuperClass.after.py b/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/SuperClass.after.py new file mode 100644 index 000000000000..d44a9e409086 --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/SuperClass.after.py @@ -0,0 +1,14 @@ +from abc import ABCMeta +from abc import abstractmethod + + +class Parent(object): + __metaclass__ = ABCMeta + + @abstractmethod + def my_method(self, foo): + pass + + @abstractmethod + def my_method_2(self, foo): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/SuperClass.py b/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/SuperClass.py new file mode 100644 index 000000000000..b63dd444c9b8 --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/SuperClass.py @@ -0,0 +1,2 @@ +class Parent(object): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/abc.py b/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/abc.py new file mode 100644 index 000000000000..ef4f2f69e838 --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodPy2AddMeta/abc.py @@ -0,0 +1,8 @@ +# Stubs + +class ABCMeta: + pass + + +def abstractmethod(foo): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/Class.after.py b/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/Class.after.py new file mode 100644 index 000000000000..c0e75fa98646 --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/Class.after.py @@ -0,0 +1,12 @@ +from SuperClass import Parent +class Child(Parent): + def my_method(self, foo): + """ + Eats eggs + :param foo: eggs + """ + bar = foo + + @classmethod + def my_class_method(): + print("Q")
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/Class.py b/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/Class.py new file mode 100644 index 000000000000..c0e75fa98646 --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/Class.py @@ -0,0 +1,12 @@ +from SuperClass import Parent +class Child(Parent): + def my_method(self, foo): + """ + Eats eggs + :param foo: eggs + """ + bar = foo + + @classmethod + def my_class_method(): + print("Q")
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/SuperClass.after.py b/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/SuperClass.after.py new file mode 100644 index 000000000000..ded9ea669c57 --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/SuperClass.after.py @@ -0,0 +1,16 @@ +from abc import ABCMeta +from abc import abstractmethod +from abc import object +class Parent(object, metaclass=ABCMeta): + @abstractmethod + def my_method(self, foo): + """ + Eats eggs + :param foo: eggs + """ + pass + + @classmethod + @abstractmethod + def my_class_method(): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/SuperClass.py b/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/SuperClass.py new file mode 100644 index 000000000000..33ba9ffac4b6 --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/SuperClass.py @@ -0,0 +1,3 @@ +from abc import object +class Parent(object): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/abc.py b/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/abc.py new file mode 100644 index 000000000000..a63732d230a2 --- /dev/null +++ b/python/testData/refactoring/pullup/abstractMethodPy3AddMeta/abc.py @@ -0,0 +1,11 @@ +# Stubs + +class object: + pass + +class ABCMeta: + pass + + +def abstractmethod(foo): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/duplicateImport/Class.after.py b/python/testData/refactoring/pullup/duplicateImport/Class.after.py new file mode 100644 index 000000000000..d1946f846ceb --- /dev/null +++ b/python/testData/refactoring/pullup/duplicateImport/Class.after.py @@ -0,0 +1,6 @@ +from SuperClass import SuperClass + + +class AnyClass(SuperClass): + pass + diff --git a/python/testData/refactoring/pullup/duplicateImport/Class.py b/python/testData/refactoring/pullup/duplicateImport/Class.py index bd19d07b851d..ca10ac1e233a 100644 --- a/python/testData/refactoring/pullup/duplicateImport/Class.py +++ b/python/testData/refactoring/pullup/duplicateImport/Class.py @@ -1,4 +1,6 @@ from SuperClass import SuperClass +import sys + from sys import argv @@ -7,3 +9,5 @@ class AnyClass(SuperClass): if not self.args: self.args = argv self.argument = some_argument + print(sys.api_version) + diff --git a/python/testData/refactoring/pullup/duplicateImport/SuperClass.after.py b/python/testData/refactoring/pullup/duplicateImport/SuperClass.after.py index 19fa11b25860..beda7cd58320 100644 --- a/python/testData/refactoring/pullup/duplicateImport/SuperClass.after.py +++ b/python/testData/refactoring/pullup/duplicateImport/SuperClass.after.py @@ -1,4 +1,6 @@ from sys import argv +import sys + class SuperClass(object): def __init__(self): @@ -8,3 +10,4 @@ class SuperClass(object): if not self.args: self.args = argv self.argument = some_argument + print(sys.api_version) diff --git a/python/testData/refactoring/pullup/fieldMove/Class.after.py b/python/testData/refactoring/pullup/fieldMove/Class.after.py new file mode 100644 index 000000000000..da34ab3a2897 --- /dev/null +++ b/python/testData/refactoring/pullup/fieldMove/Class.after.py @@ -0,0 +1,6 @@ +from SuperClass import SuperClass + + +class AnyClass(SuperClass): + def __init__(self): + super().__init__() diff --git a/python/testData/refactoring/pullup/fieldMove/Class.py b/python/testData/refactoring/pullup/fieldMove/Class.py new file mode 100644 index 000000000000..99e7fa8bcd38 --- /dev/null +++ b/python/testData/refactoring/pullup/fieldMove/Class.py @@ -0,0 +1,9 @@ +import sys +from SuperClass import SuperClass + +class AnyClass(SuperClass): + COPYRIGHT = sys.copyright + + def __init__(self): + super().__init__() + self.version = sys.api_version
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/fieldMove/SuperClass.after.py b/python/testData/refactoring/pullup/fieldMove/SuperClass.after.py new file mode 100644 index 000000000000..fc7c5e9606be --- /dev/null +++ b/python/testData/refactoring/pullup/fieldMove/SuperClass.after.py @@ -0,0 +1,8 @@ +import sys + + +class SuperClass(object): + COPYRIGHT = sys.copyright + + def __init__(self): + self.version = sys.api_version
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/fieldMove/SuperClass.py b/python/testData/refactoring/pullup/fieldMove/SuperClass.py new file mode 100644 index 000000000000..287177a637ad --- /dev/null +++ b/python/testData/refactoring/pullup/fieldMove/SuperClass.py @@ -0,0 +1,2 @@ +class SuperClass(object): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/instanceNotDeclaredInInit.after.py b/python/testData/refactoring/pullup/instanceNotDeclaredInInit.after.py new file mode 100644 index 000000000000..812bd9ce6364 --- /dev/null +++ b/python/testData/refactoring/pullup/instanceNotDeclaredInInit.after.py @@ -0,0 +1,8 @@ +class Parent(object): + def __init__(self): + self.foo = 12 + + +class Child(Parent): + def foo(self): + self.foo = 12 diff --git a/python/testData/refactoring/pullup/instanceNotDeclaredInInit.py b/python/testData/refactoring/pullup/instanceNotDeclaredInInit.py new file mode 100644 index 000000000000..9e57575195c5 --- /dev/null +++ b/python/testData/refactoring/pullup/instanceNotDeclaredInInit.py @@ -0,0 +1,7 @@ +class Parent(object): + pass + + +class Child(Parent): + def foo(self): + self.foo = 12 diff --git a/python/testData/refactoring/pullup/moveClassAttributesNoPass.after.py b/python/testData/refactoring/pullup/moveClassAttributesNoPass.after.py new file mode 100644 index 000000000000..8732118af791 --- /dev/null +++ b/python/testData/refactoring/pullup/moveClassAttributesNoPass.after.py @@ -0,0 +1,9 @@ +class Parent2: + CLASS_VAR = 42 + + def doo(self): + pass + + +class Child2(Parent2): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/moveClassAttributesNoPass.py b/python/testData/refactoring/pullup/moveClassAttributesNoPass.py new file mode 100644 index 000000000000..2454ab2d50f2 --- /dev/null +++ b/python/testData/refactoring/pullup/moveClassAttributesNoPass.py @@ -0,0 +1,7 @@ +class Parent2: + def doo(self): + pass + + +class Child2(Parent2): + CLASS_VAR = 42 diff --git a/python/testData/refactoring/pullup/moveClassAttributesSimple.after.py b/python/testData/refactoring/pullup/moveClassAttributesSimple.after.py new file mode 100644 index 000000000000..a77087153cd9 --- /dev/null +++ b/python/testData/refactoring/pullup/moveClassAttributesSimple.after.py @@ -0,0 +1,6 @@ +class Parent: + CLASS_VAR = 42 + + +class Child(Parent): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/moveClassAttributesSimple.py b/python/testData/refactoring/pullup/moveClassAttributesSimple.py new file mode 100644 index 000000000000..fbfef9f7ea13 --- /dev/null +++ b/python/testData/refactoring/pullup/moveClassAttributesSimple.py @@ -0,0 +1,6 @@ +class Parent: + pass + + +class Child(Parent): + CLASS_VAR = 42 diff --git a/python/testData/refactoring/pullup/moveInstanceAttributesLeaveEmptyInit.after.py b/python/testData/refactoring/pullup/moveInstanceAttributesLeaveEmptyInit.after.py new file mode 100644 index 000000000000..b3793334f587 --- /dev/null +++ b/python/testData/refactoring/pullup/moveInstanceAttributesLeaveEmptyInit.after.py @@ -0,0 +1,21 @@ +class Parent(object): + C = 12 + + def __init__(self): + self.foo = 12 + + def foo(self): + pass + + +class Child(Parent, object): + def __init__(self): pass + + AC = 11 + + def foo(self): + pass + + +class Bar(object): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/moveInstanceAttributesLeaveEmptyInit.py b/python/testData/refactoring/pullup/moveInstanceAttributesLeaveEmptyInit.py new file mode 100644 index 000000000000..36721bf5f1be --- /dev/null +++ b/python/testData/refactoring/pullup/moveInstanceAttributesLeaveEmptyInit.py @@ -0,0 +1,19 @@ +class Parent(object): + C = 12 + + def foo(self): + pass + + +class Child(Parent, object): + def __init__(self): + self.foo = 12 + + AC = 11 + + def foo(self): + pass + + +class Bar(object): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/moveInstanceAttributesNoInit.after.py b/python/testData/refactoring/pullup/moveInstanceAttributesNoInit.after.py new file mode 100644 index 000000000000..ec67fd6f663b --- /dev/null +++ b/python/testData/refactoring/pullup/moveInstanceAttributesNoInit.after.py @@ -0,0 +1,9 @@ +class Parent: + def __init__(self): + self.instance_field = "eggs" + + +class Child(Parent): + def __init__(self): + Parent2.__init__(self) + diff --git a/python/testData/refactoring/pullup/moveInstanceAttributesNoInit.py b/python/testData/refactoring/pullup/moveInstanceAttributesNoInit.py new file mode 100644 index 000000000000..88866c150e1d --- /dev/null +++ b/python/testData/refactoring/pullup/moveInstanceAttributesNoInit.py @@ -0,0 +1,9 @@ +class Parent: + pass + + +class Child(Parent): + def __init__(self): + Parent2.__init__(self) + self.instance_field = "eggs" + diff --git a/python/testData/refactoring/pullup/moveInstanceAttributesSimple.after.py b/python/testData/refactoring/pullup/moveInstanceAttributesSimple.after.py new file mode 100644 index 000000000000..c1d9a6b32c86 --- /dev/null +++ b/python/testData/refactoring/pullup/moveInstanceAttributesSimple.after.py @@ -0,0 +1,9 @@ +class Parent: + def __init__(self): + self.instance_field = "eggs" + + +class Child(Parent): + def __init__(self): + Parent2.__init__(self) + diff --git a/python/testData/refactoring/pullup/moveInstanceAttributesSimple.py b/python/testData/refactoring/pullup/moveInstanceAttributesSimple.py new file mode 100644 index 000000000000..2cf1c16ed2a0 --- /dev/null +++ b/python/testData/refactoring/pullup/moveInstanceAttributesSimple.py @@ -0,0 +1,10 @@ +class Parent: + def __init__(self): + pass + + +class Child(Parent): + def __init__(self): + Parent2.__init__(self) + self.instance_field = "eggs" + diff --git a/python/testData/refactoring/pullup/multiFile/Class.after.py b/python/testData/refactoring/pullup/multiFile/Class.after.py new file mode 100644 index 000000000000..1def8e5229c1 --- /dev/null +++ b/python/testData/refactoring/pullup/multiFile/Class.after.py @@ -0,0 +1,4 @@ +from SuperClass import SuperClass + +class AnyClass(SuperClass): + pass diff --git a/python/testData/refactoring/pullup/presenter/file.py b/python/testData/refactoring/pullup/presenter/file.py new file mode 100644 index 000000000000..5caadf07936f --- /dev/null +++ b/python/testData/refactoring/pullup/presenter/file.py @@ -0,0 +1,62 @@ +from datetime import datetime +from datetime import date + +class MainParent(object): + pass + +class SubParent1(MainParent): + def foo(self): + pass + pass + +class SubParent2(MainParent): + pass + +class Child(SubParent1, SubParent2): + def spam(self): + pass + pass + +class NoParentsAllowed(datetime, object): + def foo(self): + pass + pass + + +class NoMembers(object): + pass + +class BadMro(MainParent, object, SubParent1, SubParent2): + pass + +class HugeChild(SubParent1, date): #SubParent1 is disabled + def __init__(self): + self.instance_field_1 = 42 + self.instance_field_2 = 100500 + + CLASS_FIELD = 42 + (CLASS_FIELD_A,CLASS_FIELD_B) = (42,100500) #We do not support tuples in class assignments for now (see ClassFieldsManager) + def foo(self): #should be disabled + pass + def bar(self): + pass + + @classmethod + def static_1(cls): # Could be abstract in Py3K + pass + + @staticmethod + def static_2(): # Could be abstract in Py3K + pass + + + @staticmethod + def bad_method(): #Code has errors, so method should be not be marked as static + pass + +class Bar(object): + C = 1 + +class Foo(Bar): + def __init__(self): + self.foo = 12
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/severalParents.after.py b/python/testData/refactoring/pullup/severalParents.after.py new file mode 100644 index 000000000000..cd45e22d8479 --- /dev/null +++ b/python/testData/refactoring/pullup/severalParents.after.py @@ -0,0 +1,13 @@ +class Spam: + pass + +class Parent_1(object, Spam): + pass + + +class Parent_2(): + pass + + +class Child(Parent_1, Parent_2): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/severalParents.py b/python/testData/refactoring/pullup/severalParents.py new file mode 100644 index 000000000000..2c5f7a1b9ede --- /dev/null +++ b/python/testData/refactoring/pullup/severalParents.py @@ -0,0 +1,13 @@ +class Spam: + pass + +class Parent_1(object): + pass + + +class Parent_2(): + pass + + +class Child(Parent_1, Parent_2, Spam): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pullup/withComments.after.py b/python/testData/refactoring/pullup/withComments.after.py index ce91117e5413..d2d920f75a51 100644 --- a/python/testData/refactoring/pullup/withComments.after.py +++ b/python/testData/refactoring/pullup/withComments.after.py @@ -2,8 +2,10 @@ class Foo: def foo(self): print("a") - # this is boo def boo(self): + """ + In python we use multi-line comments inside of method body + """ print "rrrrr" diff --git a/python/testData/refactoring/pullup/withComments.py b/python/testData/refactoring/pullup/withComments.py index 32edbc391bf2..a044302c006b 100644 --- a/python/testData/refactoring/pullup/withComments.py +++ b/python/testData/refactoring/pullup/withComments.py @@ -3,6 +3,8 @@ class Foo: print("a") class Boo(Foo): - # this is boo def boo(self): + """ + In python we use multi-line comments inside of method body + """ print "rrrrr"
\ No newline at end of file diff --git a/python/testData/refactoring/pushdown/existingmethod.after.py b/python/testData/refactoring/pushdown/existingmethod.after.py index 25daa38234d6..b396cd5c02e3 100644 --- a/python/testData/refactoring/pushdown/existingmethod.after.py +++ b/python/testData/refactoring/pushdown/existingmethod.after.py @@ -1,5 +1,7 @@ class Foo: + pass -class Boo(): + +class Boo(Foo): def foo(self): print "rrrrr"
\ No newline at end of file diff --git a/python/testData/refactoring/pushdown/full.after.py b/python/testData/refactoring/pushdown/full.after.py new file mode 100644 index 000000000000..0845450d0805 --- /dev/null +++ b/python/testData/refactoring/pushdown/full.after.py @@ -0,0 +1,48 @@ +class Dummny(object): + pass + + +class Parent(object): + """ + This class is usefull. + """ + CLASS_VAR_2 = 2 + + def __init__(self): pass + + + def method_2(self): + i = 1 + + +class Child_1(Parent, Dummny): + CLASS_VAR_1 = 1 + + def __init__(self): + self.inst_var = 12 + self.bar = 64 + + def method_1(self): + """ + Some text + """ + pass + + +class Child_2(Parent, Dummny): + """ + This class implements most sophisticated algorithm + """ + CLASS_VAR_1 = 1 + + def __init__(self): + self.inst_var = 12 + + def lala(self): + pass + + def method_1(self): + """ + Some text + """ + pass diff --git a/python/testData/refactoring/pushdown/full.before.py b/python/testData/refactoring/pushdown/full.before.py new file mode 100644 index 000000000000..30b205bb13d2 --- /dev/null +++ b/python/testData/refactoring/pushdown/full.before.py @@ -0,0 +1,37 @@ +class Dummny(object): + pass + + +class Parent(object, Dummny): + """ + This class is usefull. + """ + CLASS_VAR_1 = 1 + CLASS_VAR_2 = 2 + + def __init__(self): + self.inst_var = 12 + + + def method_1(self): + """ + Some text + """ + pass + + def method_2(self): + i = 1 + + +class Child_1(Parent): + def __init__(self): + self.bar = 64 + pass + + +class Child_2(Parent): + """ + This class implements most sophisticated algorithm + """ + def lala(self): + pass diff --git a/python/testData/refactoring/pushdown/multiFileImports/child_module.after.py b/python/testData/refactoring/pushdown/multiFileImports/child_module.after.py new file mode 100644 index 000000000000..020596cc712f --- /dev/null +++ b/python/testData/refactoring/pushdown/multiFileImports/child_module.after.py @@ -0,0 +1,7 @@ +from parent_module import Parent +from shared_module import module_function + + +class Child(Parent): + def should_be_pushed(self): + module_function()
\ No newline at end of file diff --git a/python/testData/refactoring/pushdown/multiFileImports/child_module.py b/python/testData/refactoring/pushdown/multiFileImports/child_module.py new file mode 100644 index 000000000000..86716f1d649e --- /dev/null +++ b/python/testData/refactoring/pushdown/multiFileImports/child_module.py @@ -0,0 +1,4 @@ +from parent_module import Parent + +class Child(Parent): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pushdown/multiFileImports/parent_module.after.py b/python/testData/refactoring/pushdown/multiFileImports/parent_module.after.py new file mode 100644 index 000000000000..b63dd444c9b8 --- /dev/null +++ b/python/testData/refactoring/pushdown/multiFileImports/parent_module.after.py @@ -0,0 +1,2 @@ +class Parent(object): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/pushdown/multiFileImports/parent_module.py b/python/testData/refactoring/pushdown/multiFileImports/parent_module.py new file mode 100644 index 000000000000..aeeb4490b637 --- /dev/null +++ b/python/testData/refactoring/pushdown/multiFileImports/parent_module.py @@ -0,0 +1,6 @@ +from shared_module import module_function + + +class Parent(object): + def should_be_pushed(self): + module_function()
\ No newline at end of file diff --git a/python/testData/refactoring/pushdown/multiFileImports/shared_module.py b/python/testData/refactoring/pushdown/multiFileImports/shared_module.py new file mode 100644 index 000000000000..13fe833465ef --- /dev/null +++ b/python/testData/refactoring/pushdown/multiFileImports/shared_module.py @@ -0,0 +1,9 @@ +MODULE_CONTANT = 42 + + +def module_function(): + pass + + +class ModuleClass(object): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/unwrap/ifInIfUnwrap_after.py b/python/testData/refactoring/unwrap/ifInIfUnwrap_after.py index 68407fbdac01..1473f8fa5d3c 100644 --- a/python/testData/refactoring/unwrap/ifInIfUnwrap_after.py +++ b/python/testData/refactoring/unwrap/ifInIfUnwrap_after.py @@ -1,4 +1,4 @@ if False: - #comment + # comment x = 1<caret> y = 2 diff --git a/python/testData/refactoring/unwrap/ifInIfUnwrap_before.py b/python/testData/refactoring/unwrap/ifInIfUnwrap_before.py index 2bb897c148de..4e4fa451a2dd 100644 --- a/python/testData/refactoring/unwrap/ifInIfUnwrap_before.py +++ b/python/testData/refactoring/unwrap/ifInIfUnwrap_before.py @@ -1,5 +1,5 @@ if False: if True: - #comment + # comment x = 1<caret> y = 2 diff --git a/python/testData/refactoring/unwrap/ifInWhileUnwrap_after.py b/python/testData/refactoring/unwrap/ifInWhileUnwrap_after.py index a3de7bd76d9e..61a8c67e6564 100644 --- a/python/testData/refactoring/unwrap/ifInWhileUnwrap_after.py +++ b/python/testData/refactoring/unwrap/ifInWhileUnwrap_after.py @@ -1,4 +1,4 @@ while False: - #comment + # comment x = 1<caret> y = 2 diff --git a/python/testData/refactoring/unwrap/ifInWhileUnwrap_before.py b/python/testData/refactoring/unwrap/ifInWhileUnwrap_before.py index a612cbc9072d..b47a4d563934 100644 --- a/python/testData/refactoring/unwrap/ifInWhileUnwrap_before.py +++ b/python/testData/refactoring/unwrap/ifInWhileUnwrap_before.py @@ -1,5 +1,5 @@ while False: if True: - #comment + # comment x = 1<caret> y = 2 diff --git a/python/testData/refactoring/unwrap/whileInIfUnwrap_after.py b/python/testData/refactoring/unwrap/whileInIfUnwrap_after.py index 02d1de00f240..a855afb07096 100644 --- a/python/testData/refactoring/unwrap/whileInIfUnwrap_after.py +++ b/python/testData/refactoring/unwrap/whileInIfUnwrap_after.py @@ -1,4 +1,4 @@ if True: - #comment + # comment x = 1<caret> y = 2 diff --git a/python/testData/refactoring/unwrap/whileInIfUnwrap_before.py b/python/testData/refactoring/unwrap/whileInIfUnwrap_before.py index 3fb06a2f8c58..ddd29acd7d01 100644 --- a/python/testData/refactoring/unwrap/whileInIfUnwrap_before.py +++ b/python/testData/refactoring/unwrap/whileInIfUnwrap_before.py @@ -1,5 +1,5 @@ if True: while False: - #comment + # comment x = 1<caret> y = 2 diff --git a/python/testData/refactoring/unwrap/whileInWhileUnwrap_after.py b/python/testData/refactoring/unwrap/whileInWhileUnwrap_after.py index d5a3c2b0b464..fc23ac43c188 100644 --- a/python/testData/refactoring/unwrap/whileInWhileUnwrap_after.py +++ b/python/testData/refactoring/unwrap/whileInWhileUnwrap_after.py @@ -1,4 +1,4 @@ while True: - #comment + # comment x = 1<caret> y = 2 diff --git a/python/testData/refactoring/unwrap/whileInWhileUnwrap_before.py b/python/testData/refactoring/unwrap/whileInWhileUnwrap_before.py index 631003f6eb9d..a7cb50352474 100644 --- a/python/testData/refactoring/unwrap/whileInWhileUnwrap_before.py +++ b/python/testData/refactoring/unwrap/whileInWhileUnwrap_before.py @@ -1,5 +1,5 @@ while True: while False: - #comment + # comment x = 1<caret> y = 2 diff --git a/python/testData/wrap/DontWrapStartOfString.after.py b/python/testData/wrap/DontWrapStartOfString.after.py new file mode 100644 index 000000000000..f3fc48a40b13 --- /dev/null +++ b/python/testData/wrap/DontWrapStartOfString.after.py @@ -0,0 +1,2 @@ +call_command(' ' + 'regressiontests_some_long_text_here_to_test_right_margin_some_long_text_here_to_test_right_margin_some_long_text_here_to_test_right_margin')
\ No newline at end of file diff --git a/python/testData/wrap/DontWrapStartOfString.py b/python/testData/wrap/DontWrapStartOfString.py new file mode 100644 index 000000000000..06905d20af00 --- /dev/null +++ b/python/testData/wrap/DontWrapStartOfString.py @@ -0,0 +1 @@ +call_command(' regressiontests<caret>')
\ No newline at end of file diff --git a/python/testData/wrap/wrapRightMargin.after.py b/python/testData/wrap/wrapRightMargin.after.py index b7ed9d5c2e6c..1d20b403c0ce 100644 --- a/python/testData/wrap/wrapRightMargin.after.py +++ b/python/testData/wrap/wrapRightMargin.after.py @@ -1,4 +1,4 @@ def do_stuff(): another_long_variable = a_really_long_function_name_with_parameters(12, this_is_the_first_param=23, - this_is_the_second=45).do_more_stuff_to_the_result() + this_is_the_second=45).do_more_stuff_to_the_result() |