diff options
Diffstat (limited to 'python/testData')
82 files changed, 664 insertions, 3 deletions
diff --git a/python/testData/MockSdk2.7/python_stubs/__builtin__.py b/python/testData/MockSdk2.7/python_stubs/__builtin__.py index ca174bbf6716..5ef056b2a62c 100644 --- a/python/testData/MockSdk2.7/python_stubs/__builtin__.py +++ b/python/testData/MockSdk2.7/python_stubs/__builtin__.py @@ -652,6 +652,19 @@ class __function(object): self.__name__ = '' +class __method(object): + '''A mock class representing method type.''' + + def __init__(self): + + self.im_class = None + self.im_self = None + self.im_func = None + + self.__func__ = None + self.__self__ = None + + class __namedtuple(tuple): '''A mock base class for named tuples.''' diff --git a/python/testData/MockSdk3.2/python_stubs/builtins.py b/python/testData/MockSdk3.2/python_stubs/builtins.py index 88b74ab951ac..58fcaac8b763 100644 --- a/python/testData/MockSdk3.2/python_stubs/builtins.py +++ b/python/testData/MockSdk3.2/python_stubs/builtins.py @@ -613,14 +613,24 @@ class __function(object): self.__dict__ = '' self.__module__ = '' - self.__annotations__ = {} self.__defaults__ = {} self.__globals__ = {} - self.__kwdefaults__ = {} self.__closure__ = None self.__code__ = None self.__name__ = '' + self.__annotations__ = {} + self.__kwdefaults__ = {} + + +class __method(object): + '''A mock class representing method type.''' + + def __init__(self): + + self.__func__ = None + self.__self__ = None + class __namedtuple(tuple): '''A mock base class for named tuples.''' diff --git a/python/testData/__init__.py b/python/testData/__init__.py new file mode 100644 index 000000000000..595e3818d699 --- /dev/null +++ b/python/testData/__init__.py @@ -0,0 +1 @@ +__author__ = 'traff' diff --git a/python/testData/addImport/localFromImport.after.py b/python/testData/addImport/localFromImport.after.py new file mode 100644 index 000000000000..92920f79cf9f --- /dev/null +++ b/python/testData/addImport/localFromImport.after.py @@ -0,0 +1,6 @@ +def func(): + for _ range(10): + from package.module import foo + + foo +# <ref>
\ No newline at end of file diff --git a/python/testData/addImport/localFromImport.py b/python/testData/addImport/localFromImport.py new file mode 100644 index 000000000000..e93e2d145349 --- /dev/null +++ b/python/testData/addImport/localFromImport.py @@ -0,0 +1,4 @@ +def func(): + for _ range(10): + foo +# <ref>
\ No newline at end of file diff --git a/python/testData/addImport/localImport.after.py b/python/testData/addImport/localImport.after.py new file mode 100644 index 000000000000..883e080132c9 --- /dev/null +++ b/python/testData/addImport/localImport.after.py @@ -0,0 +1,8 @@ +def func(): + try: + import module + + module +# <ref> + except: + pass diff --git a/python/testData/addImport/localImport.py b/python/testData/addImport/localImport.py new file mode 100644 index 000000000000..942858492cb7 --- /dev/null +++ b/python/testData/addImport/localImport.py @@ -0,0 +1,6 @@ +def func(): + try: + module +# <ref> + except: + pass diff --git a/python/testData/addImport/localImportInlineBranch.after.py b/python/testData/addImport/localImportInlineBranch.after.py new file mode 100644 index 000000000000..c7f7d3881feb --- /dev/null +++ b/python/testData/addImport/localImportInlineBranch.after.py @@ -0,0 +1,6 @@ +def func(): + if True: + import module + + module +# <ref>
\ No newline at end of file diff --git a/python/testData/addImport/localImportInlineBranch.py b/python/testData/addImport/localImportInlineBranch.py new file mode 100644 index 000000000000..89d4935d17b3 --- /dev/null +++ b/python/testData/addImport/localImportInlineBranch.py @@ -0,0 +1,3 @@ +def func(): + if True: module +# <ref>
\ No newline at end of file diff --git a/python/testData/addImport/localImportInlineFunctionBody.after.py b/python/testData/addImport/localImportInlineFunctionBody.after.py new file mode 100644 index 000000000000..13d2a1e60805 --- /dev/null +++ b/python/testData/addImport/localImportInlineFunctionBody.after.py @@ -0,0 +1,5 @@ +def func(): + import module + + module +# <ref>
\ No newline at end of file diff --git a/python/testData/addImport/localImportInlineFunctionBody.py b/python/testData/addImport/localImportInlineFunctionBody.py new file mode 100644 index 000000000000..b76c83016192 --- /dev/null +++ b/python/testData/addImport/localImportInlineFunctionBody.py @@ -0,0 +1,2 @@ +def func(): module +# <ref>
\ No newline at end of file diff --git a/python/testData/completion/boundMethodSpecialAttributes.py b/python/testData/completion/boundMethodSpecialAttributes.py new file mode 100644 index 000000000000..02afa569bfbe --- /dev/null +++ b/python/testData/completion/boundMethodSpecialAttributes.py @@ -0,0 +1,5 @@ +class MyClass(object): + def method(self): + pass + +MyClass().method.__<caret>
\ No newline at end of file diff --git a/python/testData/completion/lambdaSpecialAttributes.py b/python/testData/completion/lambdaSpecialAttributes.py new file mode 100644 index 000000000000..0b0465eb2aa6 --- /dev/null +++ b/python/testData/completion/lambdaSpecialAttributes.py @@ -0,0 +1 @@ +(lambda: 42).__<caret>
\ No newline at end of file diff --git a/python/testData/completion/reassignedMethodSpecialAttributes.py b/python/testData/completion/reassignedMethodSpecialAttributes.py new file mode 100644 index 000000000000..faf25e0022c7 --- /dev/null +++ b/python/testData/completion/reassignedMethodSpecialAttributes.py @@ -0,0 +1,6 @@ +class MyClass(object): + def method(self): + pass + +m = MyClass().method +m.__<caret>
\ No newline at end of file diff --git a/python/testData/completion/staticMethodSpecialAttributes.py b/python/testData/completion/staticMethodSpecialAttributes.py new file mode 100644 index 000000000000..84b0e751af43 --- /dev/null +++ b/python/testData/completion/staticMethodSpecialAttributes.py @@ -0,0 +1,6 @@ +class MyClass(object): + @staticmethod + def method(self): + pass + +MyClass().method.__<caret>
\ No newline at end of file diff --git a/python/testData/completion/unboundMethodSpecialAttributes.py b/python/testData/completion/unboundMethodSpecialAttributes.py new file mode 100644 index 000000000000..b7e9b520de42 --- /dev/null +++ b/python/testData/completion/unboundMethodSpecialAttributes.py @@ -0,0 +1,5 @@ +class MyClass(object): + def method(self): + pass + +MyClass.method.__<caret>
\ No newline at end of file diff --git a/python/testData/completion/weakQualifierBoundMethodAttributes.py b/python/testData/completion/weakQualifierBoundMethodAttributes.py new file mode 100644 index 000000000000..2433cfbfa054 --- /dev/null +++ b/python/testData/completion/weakQualifierBoundMethodAttributes.py @@ -0,0 +1,10 @@ +class MyClass(object): + def method(self): + pass + +if True: + inst = MyClass() +else: + inst = unresolved + +inst.method.__<caret>
\ No newline at end of file diff --git a/python/testData/debug/Adder-0.1.egg b/python/testData/debug/Adder-0.1.egg Binary files differnew file mode 100644 index 000000000000..eb98b6af646a --- /dev/null +++ b/python/testData/debug/Adder-0.1.egg diff --git a/python/testData/debug/Test_Resume.py b/python/testData/debug/Test_Resume.py new file mode 100644 index 000000000000..dcec51cd4d27 --- /dev/null +++ b/python/testData/debug/Test_Resume.py @@ -0,0 +1,8 @@ +def foo(x): + print(x) + +foo(1) +foo(2) + + + diff --git a/python/testData/debug/__init__.py b/python/testData/debug/__init__.py new file mode 100644 index 000000000000..595e3818d699 --- /dev/null +++ b/python/testData/debug/__init__.py @@ -0,0 +1 @@ +__author__ = 'traff' diff --git a/python/testData/debug/pycharm-debug.egg b/python/testData/debug/pycharm-debug.egg Binary files differnew file mode 100644 index 000000000000..5a17292609c2 --- /dev/null +++ b/python/testData/debug/pycharm-debug.egg diff --git a/python/testData/debug/test1.py b/python/testData/debug/test1.py new file mode 100644 index 000000000000..f65495913ff4 --- /dev/null +++ b/python/testData/debug/test1.py @@ -0,0 +1,5 @@ +i = 0 +while True: + print(i) + i = i + 1 + diff --git a/python/testData/debug/test2.py b/python/testData/debug/test2.py new file mode 100644 index 000000000000..246363a5f482 --- /dev/null +++ b/python/testData/debug/test2.py @@ -0,0 +1,8 @@ +def foo(x): + y = x + 2 + print(y) + +z = 1 +foo(z) +z += 1 +print(z) diff --git a/python/testData/debug/test3.py b/python/testData/debug/test3.py new file mode 100644 index 000000000000..6122a530c610 --- /dev/null +++ b/python/testData/debug/test3.py @@ -0,0 +1,26 @@ +class A: + def __init__(self, z): + self.z = z + + def foo(self, x): + y = 2 * x + self.z + return 1 + y + + +def zoo(x): + y = int((x - 2) / (x - 1)) + + return A(y) + +print(zoo(2).foo(2)) + +try: + try: + print(zoo(1).foo(2)) #we got ZeroDivision here + finally: + print(zoo(0).foo(2)) +except: + pass + +a = zoo(-1) +print(a.foo(2))
\ No newline at end of file diff --git a/python/testData/debug/test4.py b/python/testData/debug/test4.py new file mode 100644 index 000000000000..b8b7e91501f2 --- /dev/null +++ b/python/testData/debug/test4.py @@ -0,0 +1,5 @@ +xval = 0 +xvalue1 = 1 +xvalue2 = 2 +print(xvalue1 + xvalue2) + diff --git a/python/testData/debug/test_continuation.py b/python/testData/debug/test_continuation.py new file mode 100644 index 000000000000..5957e3db6e82 --- /dev/null +++ b/python/testData/debug/test_continuation.py @@ -0,0 +1,16 @@ +class Boo: + def bu(self, y): + return 1 + y + + +class Foo: + def fu(self): + return Boo() + +x = 0 +print(x) +x = Foo().fu()\ +.bu(x) +print(x) +x=2 +print(x)
\ No newline at end of file diff --git a/python/testData/debug/test_continuation2.py b/python/testData/debug/test_continuation2.py new file mode 100644 index 000000000000..3b0246db511c --- /dev/null +++ b/python/testData/debug/test_continuation2.py @@ -0,0 +1,8 @@ +x = 0 +print(x) +x = 1+\ +2+\ +3 +print(x) +x=2 +print(x)
\ No newline at end of file diff --git a/python/testData/debug/test_egg.py b/python/testData/debug/test_egg.py new file mode 100644 index 000000000000..82bec29efee8 --- /dev/null +++ b/python/testData/debug/test_egg.py @@ -0,0 +1,4 @@ +from adder import adder + +x = adder.add(7, 9) +print(x)
\ No newline at end of file diff --git a/python/testData/debug/test_exceptbreak.py b/python/testData/debug/test_exceptbreak.py new file mode 100644 index 000000000000..46b0ebcb22b5 --- /dev/null +++ b/python/testData/debug/test_exceptbreak.py @@ -0,0 +1,8 @@ +def foo(x): + return 1/x + +def zoo(x): + res = foo(x) + return res + +print(zoo(0)) diff --git a/python/testData/debug/test_input.py b/python/testData/debug/test_input.py new file mode 100644 index 000000000000..5ac9bacbf418 --- /dev/null +++ b/python/testData/debug/test_input.py @@ -0,0 +1,7 @@ +while True: + promt = "print command > " + try: + string = raw_input(promt) + except : + string = input(promt) + print ("command was " + string)
\ No newline at end of file diff --git a/python/testData/debug/test_multiprocess.py b/python/testData/debug/test_multiprocess.py new file mode 100644 index 000000000000..5fc6be4625d8 --- /dev/null +++ b/python/testData/debug/test_multiprocess.py @@ -0,0 +1,13 @@ +from concurrent.futures import ProcessPoolExecutor +def my_foo(arg_): + return arg_ + +def main(): + arg = ['Result:OK'] + with ProcessPoolExecutor(1) as exec: + result = exec.map(my_foo, arg) + for i in result: + print(i) + +if __name__ == '__main__': + main()
\ No newline at end of file diff --git a/python/testData/debug/test_multithread.py b/python/testData/debug/test_multithread.py new file mode 100644 index 000000000000..03c0811ded8b --- /dev/null +++ b/python/testData/debug/test_multithread.py @@ -0,0 +1,24 @@ +try: + import thread +except : + import _thread as thread + +import threading + +def bar(y): + z = 100 + y + print("Z=%d"%z) + +def foo(x): + y = x + 1 + print("Y=%d"%y) + + t = threading.Thread(target=bar, args=(y,)) + t.start() + + +id = thread.start_new_thread(foo, (1,)) + +while True: + pass + diff --git a/python/testData/debug/test_remote.py b/python/testData/debug/test_remote.py new file mode 100644 index 000000000000..8bccbeb44c4f --- /dev/null +++ b/python/testData/debug/test_remote.py @@ -0,0 +1,19 @@ +import sys + +if __name__ == '__main__': + if len(sys.argv) < 2: + sys.stderr.write("Not enough arguments") + sys.exit(1) + + port = int(sys.argv[1]) + + x = 0 + + from pydev import pydevd + pydevd.settrace('localhost', port=port, stdoutToServer=True, stderrToServer=True) + + x = 1 + x = 2 + x = 3 + + print("OK") diff --git a/python/testData/debug/test_runtoline.py b/python/testData/debug/test_runtoline.py new file mode 100644 index 000000000000..804c56c4dcb4 --- /dev/null +++ b/python/testData/debug/test_runtoline.py @@ -0,0 +1,8 @@ +x = 0 +print(x) +while x<2: + x+=1 + print(x) + +x+=10 +print("x = %d" % x)
\ No newline at end of file diff --git a/python/testData/debug/test_stepOverCondition.py b/python/testData/debug/test_stepOverCondition.py new file mode 100644 index 000000000000..1b41c605af36 --- /dev/null +++ b/python/testData/debug/test_stepOverCondition.py @@ -0,0 +1,4 @@ +x = 1 +y = 2 +y = x + y +print(y)
\ No newline at end of file diff --git a/python/testData/debug/zipped_lib.zip b/python/testData/debug/zipped_lib.zip Binary files differnew file mode 100644 index 000000000000..fe2ac045d579 --- /dev/null +++ b/python/testData/debug/zipped_lib.zip diff --git a/python/testData/dotNet/PythonLibs.dll b/python/testData/dotNet/PythonLibs.dll Binary files differnew file mode 100644 index 000000000000..cfdfa746d3a8 --- /dev/null +++ b/python/testData/dotNet/PythonLibs.dll diff --git a/python/testData/dotNet/SingleNameSpace.dll b/python/testData/dotNet/SingleNameSpace.dll Binary files differnew file mode 100644 index 000000000000..da6dacb065f6 --- /dev/null +++ b/python/testData/dotNet/SingleNameSpace.dll diff --git a/python/testData/dotNet/__init__.py b/python/testData/dotNet/__init__.py new file mode 100644 index 000000000000..595e3818d699 --- /dev/null +++ b/python/testData/dotNet/__init__.py @@ -0,0 +1 @@ +__author__ = 'traff' diff --git a/python/testData/dotNet/expected.skeleton.Deep.py b/python/testData/dotNet/expected.skeleton.Deep.py new file mode 100644 index 000000000000..52abbf6354d4 --- /dev/null +++ b/python/testData/dotNet/expected.skeleton.Deep.py @@ -0,0 +1,17 @@ +# encoding: utf-8 +# module SingleNameSpace.Some.Deep calls itself Deep +# from SingleNameSpace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +# by generator 1.135 +# no doc +# no imports + +# no functions +# classes + +from object import object + +class WeHaveClass(object): + """ WeHaveClass() """ + MyClass = None + + diff --git a/python/testData/dotNet/expected.skeleton.SingleNameSpace.py b/python/testData/dotNet/expected.skeleton.SingleNameSpace.py new file mode 100644 index 000000000000..b2048fd39e63 --- /dev/null +++ b/python/testData/dotNet/expected.skeleton.SingleNameSpace.py @@ -0,0 +1,22 @@ +# encoding: utf-8 +# module SingleNameSpace +# from SingleNameSpace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +# by generator 1.135 +# no doc +# no imports + +# no functions +# classes + +from object import object + +class AnotherClass(object): + """ AnotherClass() """ + +from object import object + +class MyClass(object): + """ MyClass() """ + +# variables with complex values + diff --git a/python/testData/dotNet/expected.skeleton.java.py b/python/testData/dotNet/expected.skeleton.java.py new file mode 100644 index 000000000000..1ba6b3a3825a --- /dev/null +++ b/python/testData/dotNet/expected.skeleton.java.py @@ -0,0 +1,24 @@ +# encoding: utf-8 +# module com.just.like.java calls itself java +# from PythonLibs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +# by generator 1.135 +# no doc +# no imports + +# no functions +# classes + +from object import object + +class LikeJavaClass(object): + """ LikeJavaClass() """ + def likeJavaInstanceMethod(self, i): + """ likeJavaInstanceMethod(self: LikeJavaClass, i: int) -> int """ + pass + + @staticmethod + def likeJavaStaticMethod(i): + """ likeJavaStaticMethod(i: int) """ + pass + + diff --git a/python/testData/dotNet/import_class_from_module.py b/python/testData/dotNet/import_class_from_module.py new file mode 100644 index 000000000000..bf36d0e586d7 --- /dev/null +++ b/python/testData/dotNet/import_class_from_module.py @@ -0,0 +1,6 @@ +import clr + +clr.AddReferenceByPartialName("PythonLibs") + +from c<caret>om.just.like.java import LikeJavaClass +print LikeJavaClass
\ No newline at end of file diff --git a/python/testData/dotNet/import_class_from_module_alias.py b/python/testData/dotNet/import_class_from_module_alias.py new file mode 100644 index 000000000000..92d82f81abaa --- /dev/null +++ b/python/testData/dotNet/import_class_from_module_alias.py @@ -0,0 +1,6 @@ +import clr + +clr.AddReferenceByPartialName("PythonLibs") + +from c<caret>om.just.like.java import LikeJavaClass as MyClass +print MyClass
\ No newline at end of file diff --git a/python/testData/dotNet/import_module_from_package.py b/python/testData/dotNet/import_module_from_package.py new file mode 100644 index 000000000000..c31e92e05cc0 --- /dev/null +++ b/python/testData/dotNet/import_module_from_package.py @@ -0,0 +1,7 @@ +import clr + +clr.AddReferenceByPartialName("PythonLibs") + + +from c<caret>om.just.like import java +print java.LikeJavaClass
\ No newline at end of file diff --git a/python/testData/dotNet/import_several_classes_from_module.py b/python/testData/dotNet/import_several_classes_from_module.py new file mode 100644 index 000000000000..08ab814b3238 --- /dev/null +++ b/python/testData/dotNet/import_several_classes_from_module.py @@ -0,0 +1,7 @@ +import clr + +clr.AddReferenceByPartialName("PythonLibs") + +from c<caret>om.just.like.java import LikeJavaClass + +print LikeJavaClass
\ No newline at end of file diff --git a/python/testData/dotNet/import_system.py b/python/testData/dotNet/import_system.py new file mode 100644 index 000000000000..dbfc1feaa33d --- /dev/null +++ b/python/testData/dotNet/import_system.py @@ -0,0 +1,2 @@ +from S<caret>ystem.Web import AspNetHostingPermission +print AspNetHostingPermission
\ No newline at end of file diff --git a/python/testData/dotNet/inner_class.py b/python/testData/dotNet/inner_class.py new file mode 100644 index 000000000000..9a22cf5af3cd --- /dev/null +++ b/python/testData/dotNet/inner_class.py @@ -0,0 +1,6 @@ +import clr + +clr.AddReferenceByPartialName("SingleNameSpace") + +from <caret>SingleNameSpace.Some.Deep.WeHaveClass import MyClass +print MyClass
\ No newline at end of file diff --git a/python/testData/dotNet/single_class.py b/python/testData/dotNet/single_class.py new file mode 100644 index 000000000000..679e9471fe37 --- /dev/null +++ b/python/testData/dotNet/single_class.py @@ -0,0 +1,6 @@ +import clr + +clr.AddReferenceByPartialName("SingleNameSpace") + +from S<caret>ingleNameSpace import MyClass +print MyClass
\ No newline at end of file diff --git a/python/testData/dotNet/testSkeleton.py b/python/testData/dotNet/testSkeleton.py new file mode 100644 index 000000000000..c501ddff7a56 --- /dev/null +++ b/python/testData/dotNet/testSkeleton.py @@ -0,0 +1,6 @@ +import clr + +clr.AddReferenceByPartialName("PythonLibs") +import <caret>com.just.like.java + +com.just.like.java.LikeJavaClass.likeJavaStaticMethod(1) diff --git a/python/testData/dotNet/whole_namespace.py b/python/testData/dotNet/whole_namespace.py new file mode 100644 index 000000000000..b07fa0e7c1e3 --- /dev/null +++ b/python/testData/dotNet/whole_namespace.py @@ -0,0 +1,6 @@ +import clr + +clr.AddReferenceByPartialName("SingleNameSpace") + +<caret>ingleNameSpace +print SingleNameSpace.MyClass
\ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/expected.xml b/python/testData/inspections/PyStringFormatInspection/expected.xml index 62301ce56510..25e70285bd8d 100644 --- a/python/testData/inspections/PyStringFormatInspection/expected.xml +++ b/python/testData/inspections/PyStringFormatInspection/expected.xml @@ -160,4 +160,20 @@ <line>99</line> <description>Too few arguments for format string</description> </problem> + <problem> + <file>string-format.py</file> + <line>103</line> + <description>Unexpected type</description> + </problem> + <problem> + <file>string-format.py</file> + <line>104</line> + <description>Too few arguments for format string</description> + </problem> + <problem> + <file>string-format.py</file> + <line>105</line> + <description>Too many arguments for format string</description> + </problem> + </problems> diff --git a/python/testData/inspections/PyStringFormatInspection/src/string-format.py b/python/testData/inspections/PyStringFormatInspection/src/string-format.py index e60e4bb90911..972aaed6423a 100644 --- a/python/testData/inspections/PyStringFormatInspection/src/string-format.py +++ b/python/testData/inspections/PyStringFormatInspection/src/string-format.py @@ -96,4 +96,26 @@ print '%d' % string[:2] my_tuple = (1,2,3,4,5,6,7,8) print '%d, %d' % my_tuple[:7:3] print '%d, %d, %d' % my_tuple[:7:3] -print '%d, %d, %d, %d' % my_tuple[:7:3]
\ No newline at end of file +print '%d, %d, %d, %d' % my_tuple[:7:3] + +# PY-12801 +print '%d %s' % ((42,) + ('spam',)) +print '%d %s' % (('ham',) + ('spam',)) +print '%d %s' % ((42,) + ()) +print '%d' % ((42,) + ('spam',)) + +# PY-11274 +import collections +print '%(foo)s' % collections.OrderedDict(foo=None) + +class MyDict(collections.Mapping): + def __getitem__(self, key): + return 'spam' + + def __iter__(self): + yield 'spam' + + def __len__(self): + return 1 + +print '%(foo)s' % MyDict() diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/methodSpecialAttributes.py b/python/testData/inspections/PyUnresolvedReferencesInspection/methodSpecialAttributes.py new file mode 100644 index 000000000000..7a60e533a15d --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/methodSpecialAttributes.py @@ -0,0 +1,25 @@ +class MyClass(object): + def method(self): + pass + + @staticmethod + def static_method(): + pass + + +# Unbound method still treated as __method in Python 2 +MyClass.method.__func__ +MyClass.method.<warning descr="Cannot find reference '__defaults__' in 'function'">__defaults__</warning> + +# Bound method with qualifier +inst = MyClass() +inst.method.__func__ +inst.method.<warning descr="Cannot find reference '__defaults__' in 'function'">__defaults__</warning> + +# Reassigned bound method without qualifier +m = inst.method + +# Static method +# This reference should be marked as unresolved, but such warnings are suppressed for methods with decorators +inst.static_method.__func__ +inst.static_method.__defaults__ diff --git a/python/testData/refactoring/introduceConstant/fromParameterDefaultValue.after.py b/python/testData/refactoring/introduceConstant/fromParameterDefaultValue.after.py new file mode 100644 index 000000000000..3f7191e54968 --- /dev/null +++ b/python/testData/refactoring/introduceConstant/fromParameterDefaultValue.after.py @@ -0,0 +1,5 @@ +a = 1 + 2 + + +def func(x=a + 3): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/introduceConstant/fromParameterDefaultValue.py b/python/testData/refactoring/introduceConstant/fromParameterDefaultValue.py new file mode 100644 index 000000000000..507a2df4f623 --- /dev/null +++ b/python/testData/refactoring/introduceConstant/fromParameterDefaultValue.py @@ -0,0 +1,2 @@ +def func(x=<selection>1 + 2</selection> + 3): + pass
\ No newline at end of file diff --git a/python/testData/refactoring/introduceVariable/selectionBreaksBinaryOperator.after.py b/python/testData/refactoring/introduceVariable/selectionBreaksBinaryOperator.after.py new file mode 100644 index 000000000000..775927cedb39 --- /dev/null +++ b/python/testData/refactoring/introduceVariable/selectionBreaksBinaryOperator.after.py @@ -0,0 +1,3 @@ +def foo(): + a = 2 + 3 + print 1 + a
\ No newline at end of file diff --git a/python/testData/refactoring/introduceVariable/selectionBreaksBinaryOperator.py b/python/testData/refactoring/introduceVariable/selectionBreaksBinaryOperator.py new file mode 100644 index 000000000000..c5eee8c9a423 --- /dev/null +++ b/python/testData/refactoring/introduceVariable/selectionBreaksBinaryOperator.py @@ -0,0 +1,2 @@ +def foo(): + print 1 + <selection>2 + 3</selection>
\ No newline at end of file diff --git a/python/testData/testRunner/__init__.py b/python/testData/testRunner/__init__.py new file mode 100644 index 000000000000..595e3818d699 --- /dev/null +++ b/python/testData/testRunner/__init__.py @@ -0,0 +1 @@ +__author__ = 'traff' diff --git a/python/testData/testRunner/env/__init__.py b/python/testData/testRunner/env/__init__.py new file mode 100644 index 000000000000..595e3818d699 --- /dev/null +++ b/python/testData/testRunner/env/__init__.py @@ -0,0 +1 @@ +__author__ = 'traff' diff --git a/python/testData/testRunner/env/doc/__init__.py b/python/testData/testRunner/env/doc/__init__.py new file mode 100644 index 000000000000..595e3818d699 --- /dev/null +++ b/python/testData/testRunner/env/doc/__init__.py @@ -0,0 +1 @@ +__author__ = 'traff' diff --git a/python/testData/testRunner/env/doc/test1.py b/python/testData/testRunner/env/doc/test1.py new file mode 100644 index 000000000000..3fd0252bdd55 --- /dev/null +++ b/python/testData/testRunner/env/doc/test1.py @@ -0,0 +1,39 @@ +def factorial(n): + """Return the factorial of n, an exact integer >= 0. + + If the result is small enough to fit in an int, return an int. + Else return a long. + + >>> [factorial(n) for n in range(6)] + [1, 1, 2, 6, 24, 120] + """ + + import math + if not n >= 0: + raise ValueError("n must be >= 0") + if math.floor(n) != n: + raise ValueError("n must be exact integer") + if n+1 == n: # catch a value like 1e300 + raise OverflowError("n too large") + result = 1 + factor = 2 + while factor <= n: + result *= factor + factor += 1 + return result + +class FirstGoodTest: + """ + >>> [factorial(n) for n in range(6)] + [1, 1, 2, 6, 24, 120] + """ + def test_passes(self): + pass + +class SecondGoodTest: + def test_passes(self): + """ + >>> [factorial(n) for n in range(6)] + [1, 1, 2, 6, 24, 120] + """ + pass
\ No newline at end of file diff --git a/python/testData/testRunner/env/doc/test2.py b/python/testData/testRunner/env/doc/test2.py new file mode 100644 index 000000000000..e0c4619a94f6 --- /dev/null +++ b/python/testData/testRunner/env/doc/test2.py @@ -0,0 +1,39 @@ +def factorial(n): + """Return the factorial of n, an exact integer >= 0. + + If the result is small enough to fit in an int, return an int. + Else return a long. + + >>> [factorial(n) for n in range(6)] + [1, 1, 2, 6, 24, 120] + """ + + import math + if not n >= 0: + raise ValueError("n must be >= 0") + if math.floor(n) != n: + raise ValueError("n must be exact integer") + if n+1 == n: # catch a value like 1e300 + raise OverflowError("n too large") + result = 1 + factor = 2 + while factor <= n: + result *= factor + factor += 1 + return result + +class FirstGoodTest: + """ + >>> [factorial(n) for n in range(6)] + [1, 1] + """ + def test_passes(self): + pass + +class SecondGoodTest: + def test_passes(self): + """ + >>> [factorial(n) for n in range(6)] + [1, 1, 2, 6] + """ + pass
\ No newline at end of file diff --git a/python/testData/testRunner/env/nose/__init__.py b/python/testData/testRunner/env/nose/__init__.py new file mode 100644 index 000000000000..595e3818d699 --- /dev/null +++ b/python/testData/testRunner/env/nose/__init__.py @@ -0,0 +1 @@ +__author__ = 'traff' diff --git a/python/testData/testRunner/env/nose/test1.py b/python/testData/testRunner/env/nose/test1.py new file mode 100644 index 000000000000..972270f800a2 --- /dev/null +++ b/python/testData/testRunner/env/nose/test1.py @@ -0,0 +1,11 @@ +#from unittest import TestCase + +class TestNose: + def testOne(self): + assert 4 == 2*2 + + def testTwo(self): + assert True + +def testThree(): + assert 4 == 2*2 diff --git a/python/testData/testRunner/env/nose/test2.py b/python/testData/testRunner/env/nose/test2.py new file mode 100644 index 000000000000..0a6f80ec7644 --- /dev/null +++ b/python/testData/testRunner/env/nose/test2.py @@ -0,0 +1,18 @@ +#from unittest import TestCase + +class TestNose: + def testOne(self): + assert 5 == 2*2 + + def testTwo(self): + assert True + +def testThree(): + assert 4 == 2*2 + +def test_evens(): + for i in range(0, 5): + yield check_even, i, i*3 + +def check_even(n, nn): + assert n % 2 == 0 or nn % 2 == 0
\ No newline at end of file diff --git a/python/testData/testRunner/env/pytest/__init__.py b/python/testData/testRunner/env/pytest/__init__.py new file mode 100644 index 000000000000..595e3818d699 --- /dev/null +++ b/python/testData/testRunner/env/pytest/__init__.py @@ -0,0 +1 @@ +__author__ = 'traff' diff --git a/python/testData/testRunner/env/pytest/test1.py b/python/testData/testRunner/env/pytest/test1.py new file mode 100644 index 000000000000..65016345eade --- /dev/null +++ b/python/testData/testRunner/env/pytest/test1.py @@ -0,0 +1,9 @@ +class TestPyTest: + def testOne(self): + assert 4 == 2*2 + + def testTwo(self): + assert True + +def testThree(): + assert 4 == 2*2 diff --git a/python/testData/testRunner/env/pytest/test2.py b/python/testData/testRunner/env/pytest/test2.py new file mode 100644 index 000000000000..b6c7b0887aa9 --- /dev/null +++ b/python/testData/testRunner/env/pytest/test2.py @@ -0,0 +1,16 @@ +class TestPyTest: + def testOne(self): + assert 5 == 2*2 + + def testTwo(self): + assert True + +def testThree(): + assert 4 == 2*2 + +def test_evens(): + for i in range(0, 5): + yield check_even, i, i*3 + +def check_even(n, nn): + assert n % 2 == 0 or nn % 2 == 0
\ No newline at end of file diff --git a/python/testData/testRunner/env/unit/__init__.py b/python/testData/testRunner/env/unit/__init__.py new file mode 100644 index 000000000000..7c7597a4f4fb --- /dev/null +++ b/python/testData/testRunner/env/unit/__init__.py @@ -0,0 +1 @@ +__author__ = 'ktisha' diff --git a/python/testData/testRunner/env/unit/dependentTests/__init__.py b/python/testData/testRunner/env/unit/dependentTests/__init__.py new file mode 100644 index 000000000000..595e3818d699 --- /dev/null +++ b/python/testData/testRunner/env/unit/dependentTests/__init__.py @@ -0,0 +1 @@ +__author__ = 'traff' diff --git a/python/testData/testRunner/env/unit/dependentTests/test_my_class.py b/python/testData/testRunner/env/unit/dependentTests/test_my_class.py new file mode 100644 index 000000000000..8c6a68e2b69e --- /dev/null +++ b/python/testData/testRunner/env/unit/dependentTests/test_my_class.py @@ -0,0 +1,7 @@ +import unittest +from testedCode.my_class import * + +class MyClassTest(unittest.TestCase): + def test_foo(self): + c = MyClass() + self.assertEquals("bar", c.foo()) diff --git a/python/testData/testRunner/env/unit/dependentTests/testedCode/__init__.py b/python/testData/testRunner/env/unit/dependentTests/testedCode/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/python/testData/testRunner/env/unit/dependentTests/testedCode/__init__.py diff --git a/python/testData/testRunner/env/unit/dependentTests/testedCode/my_class.py b/python/testData/testRunner/env/unit/dependentTests/testedCode/my_class.py new file mode 100644 index 000000000000..fbf4632343b7 --- /dev/null +++ b/python/testData/testRunner/env/unit/dependentTests/testedCode/my_class.py @@ -0,0 +1,4 @@ +class MyClass: + def foo(self): + return "bar" +
\ No newline at end of file diff --git a/python/testData/testRunner/env/unit/subfolder/__init__.py b/python/testData/testRunner/env/unit/subfolder/__init__.py new file mode 100644 index 000000000000..595e3818d699 --- /dev/null +++ b/python/testData/testRunner/env/unit/subfolder/__init__.py @@ -0,0 +1 @@ +__author__ = 'traff' diff --git a/python/testData/testRunner/env/unit/subfolder/test2.py b/python/testData/testRunner/env/unit/subfolder/test2.py new file mode 100644 index 000000000000..b2c21b21d674 --- /dev/null +++ b/python/testData/testRunner/env/unit/subfolder/test2.py @@ -0,0 +1,7 @@ +import unittest + +class SubTest(unittest.TestCase): + def test_in_subfolder(self): + self.assertEquals("foo", "fo" + "o") + +
\ No newline at end of file diff --git a/python/testData/testRunner/env/unit/test1.py b/python/testData/testRunner/env/unit/test1.py new file mode 100644 index 000000000000..8b2daad79ca8 --- /dev/null +++ b/python/testData/testRunner/env/unit/test1.py @@ -0,0 +1,8 @@ +from unittest import TestCase + +class UTests(TestCase): + def testOne(self): + self.assertEqual(4, 2*2) + + def testTwo(self): + self.assertTrue(False or True) diff --git a/python/testData/testRunner/env/unit/test2.py b/python/testData/testRunner/env/unit/test2.py new file mode 100644 index 000000000000..c8195292d31a --- /dev/null +++ b/python/testData/testRunner/env/unit/test2.py @@ -0,0 +1,11 @@ +from unittest import TestCase + +class UTests(TestCase): + def testOne(self): + self.assertEqual(5, 2*2) + + def testTwo(self): + self.assertTrue(False) + + def testThree(self): + self.assertTrue(True) diff --git a/python/testData/testRunner/env/unit/test_file.py b/python/testData/testRunner/env/unit/test_file.py new file mode 100644 index 000000000000..9b2ed1629eb4 --- /dev/null +++ b/python/testData/testRunner/env/unit/test_file.py @@ -0,0 +1,12 @@ +import unittest + +class GoodTest(unittest.TestCase): + def test_passes(self): + self.assertEqual(2+2, 4) + +class BadTest(unittest.TestCase): + def test_fails(self): + self.assertEqual(2+2, 5) + +if __name__ == '__main__': + unittest.main() diff --git a/python/testData/testRunner/env/unit/test_folder/__init__.py b/python/testData/testRunner/env/unit/test_folder/__init__.py new file mode 100644 index 000000000000..7c7597a4f4fb --- /dev/null +++ b/python/testData/testRunner/env/unit/test_folder/__init__.py @@ -0,0 +1 @@ +__author__ = 'ktisha' diff --git a/python/testData/testRunner/env/unit/test_folder/test1.py b/python/testData/testRunner/env/unit/test_folder/test1.py new file mode 100644 index 000000000000..8b2daad79ca8 --- /dev/null +++ b/python/testData/testRunner/env/unit/test_folder/test1.py @@ -0,0 +1,8 @@ +from unittest import TestCase + +class UTests(TestCase): + def testOne(self): + self.assertEqual(4, 2*2) + + def testTwo(self): + self.assertTrue(False or True) diff --git a/python/testData/testRunner/env/unit/test_folder/test2.py b/python/testData/testRunner/env/unit/test_folder/test2.py new file mode 100644 index 000000000000..c8195292d31a --- /dev/null +++ b/python/testData/testRunner/env/unit/test_folder/test2.py @@ -0,0 +1,11 @@ +from unittest import TestCase + +class UTests(TestCase): + def testOne(self): + self.assertEqual(5, 2*2) + + def testTwo(self): + self.assertTrue(False) + + def testThree(self): + self.assertTrue(True) |