diff options
-rw-r--r-- | astroid/builder.py | 2 | ||||
-rw-r--r-- | astroid/tests/testdata/python2/data/tmp__init__.py | 0 | ||||
-rw-r--r-- | astroid/tests/testdata/python3/data/tmp__init__.py | 0 | ||||
-rw-r--r-- | astroid/tests/unittest_builder.py | 3 |
4 files changed, 4 insertions, 1 deletions
diff --git a/astroid/builder.py b/astroid/builder.py index ee3b7e25..afb9daf1 100644 --- a/astroid/builder.py +++ b/astroid/builder.py @@ -192,7 +192,7 @@ class AstroidBuilder(raw_building.InspectBuilder): modname = modname[:-9] package = True else: - package = path.find('__init__.py') > -1 if path else False + package = path is not None and os.path.splitext(os.path.basename(path))[0] == '__init__' builder = rebuilder.TreeRebuilder(self._manager) module = builder.visit_module(node, modname, node_file, package) module._import_from_nodes = builder._import_from_nodes diff --git a/astroid/tests/testdata/python2/data/tmp__init__.py b/astroid/tests/testdata/python2/data/tmp__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/astroid/tests/testdata/python2/data/tmp__init__.py diff --git a/astroid/tests/testdata/python3/data/tmp__init__.py b/astroid/tests/testdata/python3/data/tmp__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/astroid/tests/testdata/python3/data/tmp__init__.py diff --git a/astroid/tests/unittest_builder.py b/astroid/tests/unittest_builder.py index 5b860f4c..4b0c3997 100644 --- a/astroid/tests/unittest_builder.py +++ b/astroid/tests/unittest_builder.py @@ -370,6 +370,9 @@ class BuilderTest(unittest.TestCase): datap = resources.build_file('data/__init__.py', 'data.__init__') self.assertEqual(datap.name, 'data') self.assertEqual(datap.package, 1) + datap = resources.build_file('data/tmp__init__.py', 'data.tmp__init__') + self.assertEqual(datap.name, 'data.tmp__init__') + self.assertEqual(datap.package, 0) def test_yield_parent(self): """check if we added discard nodes as yield parent (w/ compiler)""" |