diff options
88 files changed, 97 insertions, 551 deletions
diff --git a/.travis.yml b/.travis.yml index d2281d35..e3a7da10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,8 +25,6 @@ before_install: - python --version - uname -a - lsb_release -a -before_script: - - find ~ -name '*.*' | cat install: - $PYTHON_EXE -m pip install pip -U - python -m pip install tox diff --git a/MANIFEST.in b/MANIFEST.in index 642d7a65..d185621c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,3 +3,5 @@ include README.rst include COPYING include COPYING.LESSER include tox.ini +recursive-include astroid/tests/testdata *.py *.zip *.egg +recursive-include astroid/brain *.py
\ No newline at end of file diff --git a/astroid/as_string.py b/astroid/as_string.py index d99aee0a..800617e7 100644 --- a/astroid/as_string.py +++ b/astroid/as_string.py @@ -193,8 +193,8 @@ class AsStringVisitor(object): def visit_excepthandler(self, node): if node.type: if node.name: - excs = 'except %s, %s' % (node.type.accept(self), - node.name.accept(self)) + excs = 'except %s as %s' % (node.type.accept(self), + node.name.accept(self)) else: excs = 'except %s' % node.type.accept(self) else: @@ -442,17 +442,6 @@ class AsStringVisitor(object): class AsStringVisitor3(AsStringVisitor): """AsStringVisitor3 overwrites some AsStringVisitor methods""" - def visit_excepthandler(self, node): - if node.type: - if node.name: - excs = 'except %s as %s' % (node.type.accept(self), - node.name.accept(self)) - else: - excs = 'except %s' % node.type.accept(self) - else: - excs = 'except' - return '%s:\n%s' % (excs, self._stmt_list(node.body)) - def visit_nonlocal(self, node): """return an astroid.Nonlocal node as string""" return 'nonlocal %s' % ', '.join(node.names) diff --git a/astroid/tests/resources.py b/astroid/tests/resources.py index 175b9d17..1390088c 100644 --- a/astroid/tests/resources.py +++ b/astroid/tests/resources.py @@ -15,8 +15,12 @@ # # You should have received a copy of the GNU Lesser General Public License along # with astroid. If not, see <http://www.gnu.org/licenses/>. +import binascii +import contextlib import os import sys +import shutil +import tempfile import pkg_resources import six @@ -25,12 +29,30 @@ from astroid import builder from astroid import MANAGER -DATA_DIR = 'testdata/python{}/'.format(sys.version_info[0]) +DATA_DIR = 'testdata' BUILTINS = six.moves.builtins.__name__ + +@contextlib.contextmanager +def _temporary_file(): + name = binascii.hexlify(os.urandom(5)).decode() + path = find(name) + try: + yield path + finally: + os.remove(path) + +@contextlib.contextmanager +def tempfile_with_content(content): + with _temporary_file() as tmp: + with open(tmp, 'wb') as stream: + stream.write(content) + yield tmp + + def find(name): return pkg_resources.resource_filename( - pkg_resources.Requirement.parse('astroid'), + 'astroid.tests', os.path.normpath(os.path.join(DATA_DIR, name))) diff --git a/testdata/python2/data/MyPyPa-0.1.0-py2.5.egg b/astroid/tests/testdata/data/MyPyPa-0.1.0-py2.5.egg Binary files differindex f62599c7..f62599c7 100644 --- a/testdata/python2/data/MyPyPa-0.1.0-py2.5.egg +++ b/astroid/tests/testdata/data/MyPyPa-0.1.0-py2.5.egg diff --git a/testdata/python2/data/MyPyPa-0.1.0-py2.5.zip b/astroid/tests/testdata/data/MyPyPa-0.1.0-py2.5.zip Binary files differindex f62599c7..f62599c7 100644 --- a/testdata/python2/data/MyPyPa-0.1.0-py2.5.zip +++ b/astroid/tests/testdata/data/MyPyPa-0.1.0-py2.5.zip diff --git a/testdata/python3/data/SSL1/Connection1.py b/astroid/tests/testdata/data/SSL1/Connection1.py index 7373271d..7373271d 100644 --- a/testdata/python3/data/SSL1/Connection1.py +++ b/astroid/tests/testdata/data/SSL1/Connection1.py diff --git a/testdata/python3/data/SSL1/__init__.py b/astroid/tests/testdata/data/SSL1/__init__.py index c83ededc..c83ededc 100644 --- a/testdata/python3/data/SSL1/__init__.py +++ b/astroid/tests/testdata/data/SSL1/__init__.py diff --git a/testdata/python2/data/__init__.py b/astroid/tests/testdata/data/__init__.py index 332e2e72..332e2e72 100644 --- a/testdata/python2/data/__init__.py +++ b/astroid/tests/testdata/data/__init__.py diff --git a/testdata/python2/data/absimp/__init__.py b/astroid/tests/testdata/data/absimp/__init__.py index b98444df..b98444df 100644 --- a/testdata/python2/data/absimp/__init__.py +++ b/astroid/tests/testdata/data/absimp/__init__.py diff --git a/testdata/python2/data/absimp/sidepackage/__init__.py b/astroid/tests/testdata/data/absimp/sidepackage/__init__.py index 239499a6..239499a6 100644 --- a/testdata/python2/data/absimp/sidepackage/__init__.py +++ b/astroid/tests/testdata/data/absimp/sidepackage/__init__.py diff --git a/testdata/python2/data/absimp/string.py b/astroid/tests/testdata/data/absimp/string.py index e68e7496..e68e7496 100644 --- a/testdata/python2/data/absimp/string.py +++ b/astroid/tests/testdata/data/absimp/string.py diff --git a/testdata/python2/data/absimport.py b/astroid/tests/testdata/data/absimport.py index f98effa6..f98effa6 100644 --- a/testdata/python2/data/absimport.py +++ b/astroid/tests/testdata/data/absimport.py diff --git a/testdata/python2/data/all.py b/astroid/tests/testdata/data/all.py index 23f7d2b6..dd86abc5 100644 --- a/testdata/python2/data/all.py +++ b/astroid/tests/testdata/data/all.py @@ -4,6 +4,6 @@ _bla = 2 other = 'o' class Aaa: pass -def func(): print 'yo' +def func(): pass __all__ = 'Aaa', '_bla', 'name' diff --git a/testdata/python2/data/appl/__init__.py b/astroid/tests/testdata/data/appl/__init__.py index d652ffd9..d652ffd9 100644 --- a/testdata/python2/data/appl/__init__.py +++ b/astroid/tests/testdata/data/appl/__init__.py diff --git a/testdata/python3/data/appl/myConnection.py b/astroid/tests/testdata/data/appl/myConnection.py index 49269534..398484ad 100644 --- a/testdata/python3/data/appl/myConnection.py +++ b/astroid/tests/testdata/data/appl/myConnection.py @@ -1,3 +1,4 @@ +from __future__ import print_function from data import SSL1 class MyConnection(SSL1.Connection): diff --git a/testdata/python2/data/descriptor_crash.py b/astroid/tests/testdata/data/descriptor_crash.py index 11fbb4a2..11fbb4a2 100644 --- a/testdata/python2/data/descriptor_crash.py +++ b/astroid/tests/testdata/data/descriptor_crash.py diff --git a/testdata/python2/data/email.py b/astroid/tests/testdata/data/email.py index dc593564..dc593564 100644 --- a/testdata/python2/data/email.py +++ b/astroid/tests/testdata/data/email.py diff --git a/testdata/python2/data/find_test/__init__.py b/astroid/tests/testdata/data/find_test/__init__.py index e69de29b..e69de29b 100644 --- a/testdata/python2/data/find_test/__init__.py +++ b/astroid/tests/testdata/data/find_test/__init__.py diff --git a/testdata/python2/data/find_test/module.py b/astroid/tests/testdata/data/find_test/module.py index e69de29b..e69de29b 100644 --- a/testdata/python2/data/find_test/module.py +++ b/astroid/tests/testdata/data/find_test/module.py diff --git a/testdata/python2/data/find_test/module2.py b/astroid/tests/testdata/data/find_test/module2.py index e69de29b..e69de29b 100644 --- a/testdata/python2/data/find_test/module2.py +++ b/astroid/tests/testdata/data/find_test/module2.py diff --git a/testdata/python2/data/find_test/noendingnewline.py b/astroid/tests/testdata/data/find_test/noendingnewline.py index e69de29b..e69de29b 100644 --- a/testdata/python2/data/find_test/noendingnewline.py +++ b/astroid/tests/testdata/data/find_test/noendingnewline.py diff --git a/testdata/python2/data/find_test/nonregr.py b/astroid/tests/testdata/data/find_test/nonregr.py index e69de29b..e69de29b 100644 --- a/testdata/python2/data/find_test/nonregr.py +++ b/astroid/tests/testdata/data/find_test/nonregr.py diff --git a/testdata/python2/data/format.py b/astroid/tests/testdata/data/format.py index 73797061..73797061 100644 --- a/testdata/python2/data/format.py +++ b/astroid/tests/testdata/data/format.py diff --git a/testdata/python2/data/lmfp/__init__.py b/astroid/tests/testdata/data/lmfp/__init__.py index 74b26b82..74b26b82 100644 --- a/testdata/python2/data/lmfp/__init__.py +++ b/astroid/tests/testdata/data/lmfp/__init__.py diff --git a/testdata/python2/data/lmfp/foo.py b/astroid/tests/testdata/data/lmfp/foo.py index 8f7de1e8..8f7de1e8 100644 --- a/testdata/python2/data/lmfp/foo.py +++ b/astroid/tests/testdata/data/lmfp/foo.py diff --git a/testdata/python2/data/module.py b/astroid/tests/testdata/data/module.py index 118b16f9..84185cfa 100644 --- a/testdata/python2/data/module.py +++ b/astroid/tests/testdata/data/module.py @@ -29,7 +29,7 @@ class YO: def __init__(self): try: self.yo = 1 - except ValueError, ex: + except ValueError as ex: pass except (NameError, TypeError): raise XXXError() @@ -66,7 +66,7 @@ class YOUPI(YO): def class_method(cls): """class method test""" - exec a in b + pass class_method = classmethod(class_method) @@ -83,6 +83,6 @@ def four_args(a, b, c, d): d = ((a) and (b)) or (c) else: c = ((a) and (b)) or (d) - map(lambda x, y: (y, x), a) + list(map(lambda x, y: (y, x), a)) redirect = four_args diff --git a/testdata/python2/data/module1abs/__init__.py b/astroid/tests/testdata/data/module1abs/__init__.py index 42949a44..42949a44 100644 --- a/testdata/python2/data/module1abs/__init__.py +++ b/astroid/tests/testdata/data/module1abs/__init__.py diff --git a/testdata/python2/data/module1abs/core.py b/astroid/tests/testdata/data/module1abs/core.py index de101117..de101117 100644 --- a/testdata/python2/data/module1abs/core.py +++ b/astroid/tests/testdata/data/module1abs/core.py diff --git a/testdata/python3/data/module2.py b/astroid/tests/testdata/data/module2.py index 582ccd98..72d08c51 100644 --- a/testdata/python3/data/module2.py +++ b/astroid/tests/testdata/data/module2.py @@ -76,8 +76,6 @@ b = (1) | (((2) & (3)) ^ (8)) bb = ((1) | (two)) | (6) ccc = ((one) & (two)) & (three) dddd = ((x) ^ (o)) ^ (r) -exec('c = 3') -exec('c = 3', {}, {}) def raise_string(a=2, *args, **kwargs): raise Exception('yo') diff --git a/testdata/python3/data/noendingnewline.py b/astroid/tests/testdata/data/noendingnewline.py index e17b92cc..e17b92cc 100644 --- a/testdata/python3/data/noendingnewline.py +++ b/astroid/tests/testdata/data/noendingnewline.py diff --git a/testdata/python2/data/nonregr.py b/astroid/tests/testdata/data/nonregr.py index 813469fe..813469fe 100644 --- a/testdata/python2/data/nonregr.py +++ b/astroid/tests/testdata/data/nonregr.py diff --git a/testdata/python3/data/notall.py b/astroid/tests/testdata/data/notall.py index 9d35aa3a..9d35aa3a 100644 --- a/testdata/python3/data/notall.py +++ b/astroid/tests/testdata/data/notall.py diff --git a/testdata/python2/data/notamodule/file.py b/astroid/tests/testdata/data/notamodule/file.py index e69de29b..e69de29b 100644 --- a/testdata/python2/data/notamodule/file.py +++ b/astroid/tests/testdata/data/notamodule/file.py diff --git a/testdata/python2/data/package/__init__.py b/astroid/tests/testdata/data/package/__init__.py index 575d18b1..575d18b1 100644 --- a/testdata/python2/data/package/__init__.py +++ b/astroid/tests/testdata/data/package/__init__.py diff --git a/testdata/python2/data/package/absimport.py b/astroid/tests/testdata/data/package/absimport.py index 33ed117c..33ed117c 100644 --- a/testdata/python2/data/package/absimport.py +++ b/astroid/tests/testdata/data/package/absimport.py diff --git a/testdata/python2/data/package/hello.py b/astroid/tests/testdata/data/package/hello.py index b154c844..b154c844 100644 --- a/testdata/python2/data/package/hello.py +++ b/astroid/tests/testdata/data/package/hello.py diff --git a/testdata/python2/data/package/import_package_subpackage_module.py b/astroid/tests/testdata/data/package/import_package_subpackage_module.py index ad442c16..ad442c16 100644 --- a/testdata/python2/data/package/import_package_subpackage_module.py +++ b/astroid/tests/testdata/data/package/import_package_subpackage_module.py diff --git a/testdata/python2/data/package/subpackage/__init__.py b/astroid/tests/testdata/data/package/subpackage/__init__.py index dc4782e6..dc4782e6 100644 --- a/testdata/python2/data/package/subpackage/__init__.py +++ b/astroid/tests/testdata/data/package/subpackage/__init__.py diff --git a/testdata/python2/data/package/subpackage/module.py b/astroid/tests/testdata/data/package/subpackage/module.py index 4b7244ba..4b7244ba 100644 --- a/testdata/python2/data/package/subpackage/module.py +++ b/astroid/tests/testdata/data/package/subpackage/module.py diff --git a/testdata/python2/data/recursion.py b/astroid/tests/testdata/data/recursion.py index a34dad32..85f65134 100644 --- a/testdata/python2/data/recursion.py +++ b/astroid/tests/testdata/data/recursion.py @@ -1,3 +1,3 @@ -""" For issue #25 """
-class Base(object):
+""" For issue #25 """ +class Base(object): pass
\ No newline at end of file diff --git a/testdata/python2/data/unicode_package/__init__.py b/astroid/tests/testdata/data/unicode_package/__init__.py index 713e5591..713e5591 100644 --- a/testdata/python2/data/unicode_package/__init__.py +++ b/astroid/tests/testdata/data/unicode_package/__init__.py diff --git a/testdata/python2/data/unicode_package/core/__init__.py b/astroid/tests/testdata/data/unicode_package/core/__init__.py index e69de29b..e69de29b 100644 --- a/testdata/python2/data/unicode_package/core/__init__.py +++ b/astroid/tests/testdata/data/unicode_package/core/__init__.py diff --git a/astroid/tests/unittest_builder.py b/astroid/tests/unittest_builder.py index 206c7da2..813c2e3d 100644 --- a/astroid/tests/unittest_builder.py +++ b/astroid/tests/unittest_builder.py @@ -39,7 +39,41 @@ BUILTINS = six.moves.builtins.__name__ class FromToLineNoTest(unittest.TestCase): def setUp(self): - self.astroid = resources.build_file('data/format.py') + self.astroid = builder.parse(''' + """A multiline string + """ + + function('aeozrijz\ + earzer', hop) + # XXX write test + x = [i for i in range(5) + if i % 4] + + fonction(1, + 2, + 3, + 4) + + def definition(a, + b, + c): + return a + b + c + + class debile(dict, + object): + pass + + if aaaa: pass + else: + aaaa,bbbb = 1,2 + aaaa,bbbb = bbbb,aaaa + # XXX write test + hop = \ + aaaa + + + __revision__.lower(); + ''') def test_callfunc_lineno(self): stmts = self.astroid.body @@ -48,16 +82,16 @@ class FromToLineNoTest(unittest.TestCase): # earzer', hop) discard = stmts[0] self.assertIsInstance(discard, nodes.Expr) - self.assertEqual(discard.fromlineno, 4) + self.assertEqual(discard.fromlineno, 5) self.assertEqual(discard.tolineno, 5) callfunc = discard.value self.assertIsInstance(callfunc, nodes.Call) - self.assertEqual(callfunc.fromlineno, 4) + self.assertEqual(callfunc.fromlineno, 5) self.assertEqual(callfunc.tolineno, 5) name = callfunc.func self.assertIsInstance(name, nodes.Name) - self.assertEqual(name.fromlineno, 4) - self.assertEqual(name.tolineno, 4) + self.assertEqual(name.fromlineno, 5) + self.assertEqual(name.tolineno, 5) strarg = callfunc.args[0] self.assertIsInstance(strarg, nodes.Const) if hasattr(sys, 'pypy_version_info'): @@ -263,10 +297,6 @@ class BuilderTest(unittest.TestCase): with self.assertRaises(exceptions.AstroidSyntaxError): self.builder.string_build('"\\x1"') - def test_missing_newline(self): - """check that a file with no trailing new line is parseable""" - resources.build_file('data/noendingnewline.py') - def test_missing_file(self): with self.assertRaises(exceptions.AstroidBuildingError): resources.build_file('data/inexistant.py') @@ -711,7 +741,8 @@ class FileBuildTest(unittest.TestCase): def test_unknown_encoding(self): with self.assertRaises(exceptions.AstroidSyntaxError): - resources.build_file('data/invalid_encoding.py') + with resources.tempfile_with_content(b'# -*- coding: lala -*-') as tmp: + builder.AstroidBuilder().file_build(tmp) class ModuleBuildTest(resources.SysPathSetup, FileBuildTest): diff --git a/astroid/tests/unittest_modutils.py b/astroid/tests/unittest_modutils.py index 3740aa26..6dfd3bd8 100644 --- a/astroid/tests/unittest_modutils.py +++ b/astroid/tests/unittest_modutils.py @@ -244,6 +244,7 @@ class GetModuleFilesTest(unittest.TestCase): def test_get_module_files_1(self): package = resources.find('data/find_test') modules = set(modutils.get_module_files(package, [])) + expected = ['__init__.py', 'module.py', 'module2.py', 'noendingnewline.py', 'nonregr.py'] self.assertEqual(modules, @@ -254,6 +255,7 @@ class GetModuleFilesTest(unittest.TestCase): """ non_package = resources.find('data/notamodule') modules = modutils.get_module_files(non_package, [], list_all=True) + self.assertEqual( modules, [os.path.join(non_package, 'file.py')], diff --git a/astroid/tests/unittest_nodes.py b/astroid/tests/unittest_nodes.py index fab82eef..acfb817c 100644 --- a/astroid/tests/unittest_nodes.py +++ b/astroid/tests/unittest_nodes.py @@ -106,6 +106,7 @@ class AsStringTest(resources.SysPathSetup, unittest.TestCase): with open(resources.find('data/module.py'), 'r') as fobj: self.assertMultiLineEqual(module.as_string(), fobj.read()) + maxDiff = None def test_module2_as_string(self): """check as_string on a whole module prepared to be returned identically """ diff --git a/astroid/tests/unittest_scoped_nodes.py b/astroid/tests/unittest_scoped_nodes.py index d9600365..edc72caa 100644 --- a/astroid/tests/unittest_scoped_nodes.py +++ b/astroid/tests/unittest_scoped_nodes.py @@ -110,9 +110,23 @@ class ModuleNodeTest(ModuleLoader, unittest.TestCase): self.assertRaises(InferenceError, self.nonregr.igetattr, 'YOAA') def test_wildcard_import_names(self): - m = resources.build_file('data/all.py', 'all') + m = builder.parse(''' + name = 'a' + _bla = 2 + other = 'o' + class Aaa: pass + def func(): print('yo') + __all__ = 'Aaa', '_bla', 'name' + ''') self.assertEqual(m.wildcard_import_names(), ['Aaa', '_bla', 'name']) - m = resources.build_file('data/notall.py', 'notall') + m = builder.parse(''' + name = 'a' + _bla = 2 + other = 'o' + class Aaa: pass + + def func(): return 'yo' + ''') res = sorted(m.wildcard_import_names()) self.assertEqual(res, ['Aaa', 'func', 'name', 'other']) @@ -214,14 +228,14 @@ class ModuleNodeTest(ModuleLoader, unittest.TestCase): self.assertEqual(stream.read().decode(), data) def test_file_stream_physical(self): - path = resources.find('data/all.py') + path = resources.find('data/absimport.py') astroid = builder.AstroidBuilder().file_build(path, 'all') with open(path, 'rb') as file_io: with astroid.stream() as stream: self.assertEqual(stream.read(), file_io.read()) def test_stream_api(self): - path = resources.find('data/all.py') + path = resources.find('data/absimport.py') astroid = builder.AstroidBuilder().file_build(path, 'all') stream = astroid.stream() self.assertTrue(hasattr(stream, 'close')) diff --git a/testdata/python2/data/SSL1/Connection1.py b/testdata/python2/data/SSL1/Connection1.py deleted file mode 100644 index 6bbb1302..00000000 --- a/testdata/python2/data/SSL1/Connection1.py +++ /dev/null @@ -1,14 +0,0 @@ -"""M2Crypto.SSL.Connection - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" -from __future__ import print_function -RCS_id='$Id: Connection1.py,v 1.1 2005-06-13 20:55:22 syt Exp $' - -#Some code deleted here - -class Connection: - - """An SSL connection.""" - - def __init__(self, ctx, sock=None): - print('init Connection') diff --git a/testdata/python2/data/SSL1/__init__.py b/testdata/python2/data/SSL1/__init__.py deleted file mode 100644 index a007b049..00000000 --- a/testdata/python2/data/SSL1/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from Connection1 import Connection diff --git a/testdata/python2/data/appl/myConnection.py b/testdata/python2/data/appl/myConnection.py deleted file mode 100644 index 5b24b259..00000000 --- a/testdata/python2/data/appl/myConnection.py +++ /dev/null @@ -1,12 +0,0 @@ -from __future__ import print_function -from data import SSL1 -class MyConnection(SSL1.Connection): - - """An SSL connection.""" - - def __init__(self, dummy): - print('MyConnection init') - -if __name__ == '__main__': - myConnection = MyConnection(' ') - raw_input('Press Enter to continue...') diff --git a/testdata/python2/data/invalid_encoding.py b/testdata/python2/data/invalid_encoding.py deleted file mode 100644 index dddd208e..00000000 --- a/testdata/python2/data/invalid_encoding.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: lala -*-
\ No newline at end of file diff --git a/testdata/python2/data/module2.py b/testdata/python2/data/module2.py deleted file mode 100644 index 0a1bd1ad..00000000 --- a/testdata/python2/data/module2.py +++ /dev/null @@ -1,143 +0,0 @@ -from data.module import YO, YOUPI -import data - - -class Specialization(YOUPI, YO): - pass - - - -class Metaclass(type): - pass - - - -class Interface: - pass - - - -class MyIFace(Interface): - pass - - - -class AnotherIFace(Interface): - pass - - - -class MyException(Exception): - pass - - - -class MyError(MyException): - pass - - - -class AbstractClass(object): - - def to_override(self, whatever): - raise NotImplementedError() - - def return_something(self, param): - if param: - return 'toto' - return - - - -class Concrete0: - __implements__ = MyIFace - - - -class Concrete1: - __implements__ = (MyIFace, AnotherIFace) - - - -class Concrete2: - __implements__ = (MyIFace, AnotherIFace) - - - -class Concrete23(Concrete1): - pass - -del YO.member -del YO -[SYN1, SYN2] = (Concrete0, Concrete1) -assert '1' -b = (1) | (((2) & (3)) ^ (8)) -bb = ((1) | (two)) | (6) -ccc = ((one) & (two)) & (three) -dddd = ((x) ^ (o)) ^ (r) -exec 'c = 3' -exec 'c = 3' in {}, {} - -def raise_string(a=2, *args, **kwargs): - raise Exception, 'yo' - yield 'coucou' - yield -a = (b) + (2) -c = (b) * (2) -c = (b) / (2) -c = (b) // (2) -c = (b) - (2) -c = (b) % (2) -c = (b) ** (2) -c = (b) << (2) -c = (b) >> (2) -c = ~b -c = not b -d = [c] -e = d[:] -e = d[a:b:c] -raise_string(*args, **kwargs) -print >> stream, 'bonjour' -print >> stream, 'salut', - -def make_class(any, base=data.module.YO, *args, **kwargs): - """check base is correctly resolved to Concrete0""" - - - class Aaaa(base): - """dynamic class""" - - - return Aaaa -from os.path import abspath -import os as myos - - -class A: - pass - - - -class A(A): - pass - - -def generator(): - """A generator.""" - yield - -def not_a_generator(): - """A function that contains generator, but is not one.""" - - def generator(): - yield - genl = lambda : (yield) - -def with_metaclass(meta, *bases): - return meta('NewBase', bases, {}) - - -class NotMetaclass(with_metaclass(Metaclass)): - pass - - diff --git a/testdata/python2/data/noendingnewline.py b/testdata/python2/data/noendingnewline.py deleted file mode 100644 index e1d6e4a1..00000000 --- a/testdata/python2/data/noendingnewline.py +++ /dev/null @@ -1,36 +0,0 @@ -import unittest - - -class TestCase(unittest.TestCase): - - def setUp(self): - unittest.TestCase.setUp(self) - - - def tearDown(self): - unittest.TestCase.tearDown(self) - - def testIt(self): - self.a = 10 - self.xxx() - - - def xxx(self): - if False: - pass - print 'a' - - if False: - pass - pass - - if False: - pass - print 'rara' - - -if __name__ == '__main__': - print 'test2' - unittest.main() - - diff --git a/testdata/python2/data/notall.py b/testdata/python2/data/notall.py deleted file mode 100644 index 042491e0..00000000 --- a/testdata/python2/data/notall.py +++ /dev/null @@ -1,7 +0,0 @@ -name = 'a' -_bla = 2 -other = 'o' -class Aaa: pass - -def func(): return 'yo' - diff --git a/testdata/python3/data/MyPyPa-0.1.0-py2.5.egg b/testdata/python3/data/MyPyPa-0.1.0-py2.5.egg Binary files differdeleted file mode 100644 index f62599c7..00000000 --- a/testdata/python3/data/MyPyPa-0.1.0-py2.5.egg +++ /dev/null diff --git a/testdata/python3/data/MyPyPa-0.1.0-py2.5.zip b/testdata/python3/data/MyPyPa-0.1.0-py2.5.zip Binary files differdeleted file mode 100644 index f62599c7..00000000 --- a/testdata/python3/data/MyPyPa-0.1.0-py2.5.zip +++ /dev/null diff --git a/testdata/python3/data/__init__.py b/testdata/python3/data/__init__.py deleted file mode 100644 index 332e2e72..00000000 --- a/testdata/python3/data/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__revision__="$Id: __init__.py,v 1.1 2005-06-13 20:55:20 syt Exp $" diff --git a/testdata/python3/data/absimp/__init__.py b/testdata/python3/data/absimp/__init__.py deleted file mode 100644 index b98444df..00000000 --- a/testdata/python3/data/absimp/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""a package with absolute import activated -""" - -from __future__ import absolute_import - diff --git a/testdata/python3/data/absimp/sidepackage/__init__.py b/testdata/python3/data/absimp/sidepackage/__init__.py deleted file mode 100644 index 239499a6..00000000 --- a/testdata/python3/data/absimp/sidepackage/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -"""a side package with nothing in it -""" - diff --git a/testdata/python3/data/absimp/string.py b/testdata/python3/data/absimp/string.py deleted file mode 100644 index e68e7496..00000000 --- a/testdata/python3/data/absimp/string.py +++ /dev/null @@ -1,3 +0,0 @@ -from __future__ import absolute_import, print_function -import string -print(string) diff --git a/testdata/python3/data/absimport.py b/testdata/python3/data/absimport.py deleted file mode 100644 index 88f9d955..00000000 --- a/testdata/python3/data/absimport.py +++ /dev/null @@ -1,3 +0,0 @@ - -import email -from email import message diff --git a/testdata/python3/data/all.py b/testdata/python3/data/all.py deleted file mode 100644 index 587765b5..00000000 --- a/testdata/python3/data/all.py +++ /dev/null @@ -1,9 +0,0 @@ - -name = 'a' -_bla = 2 -other = 'o' -class Aaa: pass - -def func(): print('yo') - -__all__ = 'Aaa', '_bla', 'name' diff --git a/testdata/python3/data/appl/__init__.py b/testdata/python3/data/appl/__init__.py deleted file mode 100644 index d652ffd9..00000000 --- a/testdata/python3/data/appl/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -""" -Init -""" diff --git a/testdata/python3/data/descriptor_crash.py b/testdata/python3/data/descriptor_crash.py deleted file mode 100644 index 11fbb4a2..00000000 --- a/testdata/python3/data/descriptor_crash.py +++ /dev/null @@ -1,11 +0,0 @@ - -import urllib - -class Page(object): - _urlOpen = staticmethod(urllib.urlopen) - - def getPage(self, url): - handle = self._urlOpen(url) - data = handle.read() - handle.close() - return data diff --git a/testdata/python3/data/email.py b/testdata/python3/data/email.py deleted file mode 100644 index dc593564..00000000 --- a/testdata/python3/data/email.py +++ /dev/null @@ -1 +0,0 @@ -"""fake email module to test absolute import doesn't grab this one""" diff --git a/testdata/python3/data/find_test/__init__.py b/testdata/python3/data/find_test/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/testdata/python3/data/find_test/__init__.py +++ /dev/null diff --git a/testdata/python3/data/find_test/module.py b/testdata/python3/data/find_test/module.py deleted file mode 100644 index e69de29b..00000000 --- a/testdata/python3/data/find_test/module.py +++ /dev/null diff --git a/testdata/python3/data/find_test/module2.py b/testdata/python3/data/find_test/module2.py deleted file mode 100644 index e69de29b..00000000 --- a/testdata/python3/data/find_test/module2.py +++ /dev/null diff --git a/testdata/python3/data/find_test/noendingnewline.py b/testdata/python3/data/find_test/noendingnewline.py deleted file mode 100644 index e69de29b..00000000 --- a/testdata/python3/data/find_test/noendingnewline.py +++ /dev/null diff --git a/testdata/python3/data/find_test/nonregr.py b/testdata/python3/data/find_test/nonregr.py deleted file mode 100644 index e69de29b..00000000 --- a/testdata/python3/data/find_test/nonregr.py +++ /dev/null diff --git a/testdata/python3/data/format.py b/testdata/python3/data/format.py deleted file mode 100644 index 73797061..00000000 --- a/testdata/python3/data/format.py +++ /dev/null @@ -1,34 +0,0 @@ -"""A multiline string -""" - -function('aeozrijz\ -earzer', hop) -# XXX write test -x = [i for i in range(5) - if i % 4] - -fonction(1, - 2, - 3, - 4) - -def definition(a, - b, - c): - return a + b + c - -class debile(dict, - object): - pass - -if aaaa: pass -else: - aaaa,bbbb = 1,2 - aaaa,bbbb = bbbb,aaaa -# XXX write test -hop = \ - aaaa - - -__revision__.lower(); - diff --git a/testdata/python3/data/invalid_encoding.py b/testdata/python3/data/invalid_encoding.py deleted file mode 100644 index dddd208e..00000000 --- a/testdata/python3/data/invalid_encoding.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: lala -*-
\ No newline at end of file diff --git a/testdata/python3/data/lmfp/__init__.py b/testdata/python3/data/lmfp/__init__.py deleted file mode 100644 index 74b26b82..00000000 --- a/testdata/python3/data/lmfp/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# force a "direct" python import -from . import foo diff --git a/testdata/python3/data/lmfp/foo.py b/testdata/python3/data/lmfp/foo.py deleted file mode 100644 index 8f7de1e8..00000000 --- a/testdata/python3/data/lmfp/foo.py +++ /dev/null @@ -1,6 +0,0 @@ -import sys -if not getattr(sys, 'bar', None): - sys.just_once = [] -# there used to be two numbers here because -# of a load_module_from_path bug -sys.just_once.append(42) diff --git a/testdata/python3/data/module.py b/testdata/python3/data/module.py deleted file mode 100644 index da4d7afb..00000000 --- a/testdata/python3/data/module.py +++ /dev/null @@ -1,87 +0,0 @@ -"""test module for astroid -""" - -__revision__ = '$Id: module.py,v 1.2 2005-11-02 11:56:54 syt Exp $' -from astroid.tree.node_classes import Name as NameNode -from astroid import modutils -from astroid.utils import * -import os.path -MY_DICT = {} - -def global_access(key, val): - """function test""" - local = 1 - MY_DICT[key] = val - for i in val: - if i: - del MY_DICT[i] - continue - else: - break - else: - return - - -class YO: - """hehe""" - a = 1 - - def __init__(self): - try: - self.yo = 1 - except ValueError as ex: - pass - except (NameError, TypeError): - raise XXXError() - except: - raise - - - -class YOUPI(YO): - class_attr = None - - def __init__(self): - self.member = None - - def method(self): - """method test""" - try: - MY_DICT = {} - local = None - autre = [a for (a, b) in MY_DICT if b] - if b in autre: - return - else: - if a in autre: - return 'hehe' - global_access(local, val=autre) - finally: - return local - - def static_method(): - """static method test""" - assert MY_DICT, '???' - static_method = staticmethod(static_method) - - def class_method(cls): - """class method test""" - exec(a, b) - class_method = classmethod(class_method) - - -def four_args(a, b, c, d): - """four arguments (was nested_args)""" - while 1: - if a: - break - a += +1 - else: - b += -2 - if c: - d = ((a) and (b)) or (c) - else: - c = ((a) and (b)) or (d) - list(map(lambda x, y: (y, x), a)) -redirect = four_args - diff --git a/testdata/python3/data/module1abs/__init__.py b/testdata/python3/data/module1abs/__init__.py deleted file mode 100644 index f9d5b686..00000000 --- a/testdata/python3/data/module1abs/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ - -from . import core -from .core import * -print(sys.version) diff --git a/testdata/python3/data/module1abs/core.py b/testdata/python3/data/module1abs/core.py deleted file mode 100644 index de101117..00000000 --- a/testdata/python3/data/module1abs/core.py +++ /dev/null @@ -1 +0,0 @@ -import sys diff --git a/testdata/python3/data/nonregr.py b/testdata/python3/data/nonregr.py deleted file mode 100644 index 78765c85..00000000 --- a/testdata/python3/data/nonregr.py +++ /dev/null @@ -1,57 +0,0 @@ - - -try: - enumerate = enumerate -except NameError: - - def enumerate(iterable): - """emulates the python2.3 enumerate() function""" - i = 0 - for val in iterable: - yield i, val - i += 1 - -def toto(value): - for k, v in value: - print(v.get('yo')) - - -import imp -fp, mpath, desc = imp.find_module('optparse',a) -s_opt = imp.load_module('std_optparse', fp, mpath, desc) - -class OptionParser(s_opt.OptionParser): - - def parse_args(self, args=None, values=None, real_optparse=False): - if real_optparse: - pass -## return super(OptionParser, self).parse_args() - else: - import optcomp - optcomp.completion(self) - - -class Aaa(object): - """docstring""" - def __init__(self): - self.__setattr__('a','b') - pass - - def one_public(self): - """docstring""" - pass - - def another_public(self): - """docstring""" - pass - -class Ccc(Aaa): - """docstring""" - - class Ddd(Aaa): - """docstring""" - pass - - class Eee(Ddd): - """docstring""" - pass diff --git a/testdata/python3/data/notamodule/file.py b/testdata/python3/data/notamodule/file.py deleted file mode 100644 index e69de29b..00000000 --- a/testdata/python3/data/notamodule/file.py +++ /dev/null diff --git a/testdata/python3/data/package/__init__.py b/testdata/python3/data/package/__init__.py deleted file mode 100644 index 575d18b1..00000000 --- a/testdata/python3/data/package/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -"""package's __init__ file""" - - -from . import subpackage diff --git a/testdata/python3/data/package/absimport.py b/testdata/python3/data/package/absimport.py deleted file mode 100644 index 33ed117c..00000000 --- a/testdata/python3/data/package/absimport.py +++ /dev/null @@ -1,6 +0,0 @@ -from __future__ import absolute_import, print_function -import import_package_subpackage_module # fail -print(import_package_subpackage_module) - -from . import hello as hola - diff --git a/testdata/python3/data/package/hello.py b/testdata/python3/data/package/hello.py deleted file mode 100644 index b154c844..00000000 --- a/testdata/python3/data/package/hello.py +++ /dev/null @@ -1,2 +0,0 @@ -"""hello module""" - diff --git a/testdata/python3/data/package/import_package_subpackage_module.py b/testdata/python3/data/package/import_package_subpackage_module.py deleted file mode 100644 index ad442c16..00000000 --- a/testdata/python3/data/package/import_package_subpackage_module.py +++ /dev/null @@ -1,49 +0,0 @@ -# pylint: disable-msg=I0011,C0301,W0611 -"""I found some of my scripts trigger off an AttributeError in pylint -0.8.1 (with common 0.12.0 and astroid 0.13.1). - -Traceback (most recent call last): - File "/usr/bin/pylint", line 4, in ? - lint.Run(sys.argv[1:]) - File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 729, in __init__ - linter.check(args) - File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 412, in check - self.check_file(filepath, modname, checkers) - File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 426, in check_file - astroid = self._check_file(filepath, modname, checkers) - File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 450, in _check_file - self.check_astroid_module(astroid, checkers) - File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 494, in check_astroid_module - self.astroid_events(astroid, [checker for checker in checkers - File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astroid_events - self.astroid_events(child, checkers, _reversed_checkers) - File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astroid_events - self.astroid_events(child, checkers, _reversed_checkers) - File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 508, in astroid_events - checker.visit(astroid) - File "/usr/lib/python2.4/site-packages/logilab/astroid/utils.py", line 84, in visit - method(node) - File "/usr/lib/python2.4/site-packages/pylint/checkers/variables.py", line 295, in visit_import - self._check_module_attrs(node, module, name_parts[1:]) - File "/usr/lib/python2.4/site-packages/pylint/checkers/variables.py", line 357, in _check_module_attrs - self.add_message('E0611', args=(name, module.name), -AttributeError: Import instance has no attribute 'name' - - -You can reproduce it by: -(1) create package structure like the following: - -package/ - __init__.py - subpackage/ - __init__.py - module.py - -(2) in package/__init__.py write: - -import subpackage - -(3) run pylint with a script importing package.subpackage.module. -""" -__revision__ = '$Id: import_package_subpackage_module.py,v 1.1 2005-11-10 15:59:32 syt Exp $' -import package.subpackage.module diff --git a/testdata/python3/data/package/subpackage/__init__.py b/testdata/python3/data/package/subpackage/__init__.py deleted file mode 100644 index dc4782e6..00000000 --- a/testdata/python3/data/package/subpackage/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""package.subpackage""" diff --git a/testdata/python3/data/package/subpackage/module.py b/testdata/python3/data/package/subpackage/module.py deleted file mode 100644 index 4b7244ba..00000000 --- a/testdata/python3/data/package/subpackage/module.py +++ /dev/null @@ -1 +0,0 @@ -"""package.subpackage.module""" diff --git a/testdata/python3/data/recursion.py b/testdata/python3/data/recursion.py deleted file mode 100644 index a34dad32..00000000 --- a/testdata/python3/data/recursion.py +++ /dev/null @@ -1,3 +0,0 @@ -""" For issue #25 """
-class Base(object):
- pass
\ No newline at end of file diff --git a/testdata/python3/data/unicode_package/__init__.py b/testdata/python3/data/unicode_package/__init__.py deleted file mode 100644 index 713e5591..00000000 --- a/testdata/python3/data/unicode_package/__init__.py +++ /dev/null @@ -1 +0,0 @@ -x = "șțîâ"
\ No newline at end of file diff --git a/testdata/python3/data/unicode_package/core/__init__.py b/testdata/python3/data/unicode_package/core/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/testdata/python3/data/unicode_package/core/__init__.py +++ /dev/null |