summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFELD Boris <lothiraldan@gmail.com>2012-07-25 12:04:28 +0100
committerFELD Boris <lothiraldan@gmail.com>2012-07-25 12:04:28 +0100
commit19abe20cac050e5dc059fbd8cfec2277a01d0c13 (patch)
treebee58146b6da91e880b1702190b84628ddfaf24e
parent3203eb1204a0ea5e385d5f5726c2993c1d832eb0 (diff)
downloadastroid-git-19abe20cac050e5dc059fbd8cfec2277a01d0c13.tar.gz
Make Starred node extends ParentAssignTypeMixin as it can be part of Assign ast node in python-3k. Closes #83138.
-rw-r--r--node_classes.py2
-rw-r--r--test/unittest_python3.py46
2 files changed, 47 insertions, 1 deletions
diff --git a/node_classes.py b/node_classes.py
index 607ad907..7b196af6 100644
--- a/node_classes.py
+++ b/node_classes.py
@@ -745,7 +745,7 @@ class Slice(NodeNG):
upper = None
step = None
-class Starred(NodeNG):
+class Starred(NodeNG, ParentAssignTypeMixin):
"""class representing a Starred node"""
_astng_fields = ('value',)
value = None
diff --git a/test/unittest_python3.py b/test/unittest_python3.py
new file mode 100644
index 00000000..4674740e
--- /dev/null
+++ b/test/unittest_python3.py
@@ -0,0 +1,46 @@
+# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
+# copyright 2003-2010 Sylvain Thenault, all rights reserved.
+# contact mailto:thenault@gmail.com
+#
+# This file is part of logilab-astng.
+#
+# logilab-astng is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by the
+# Free Software Foundation, either version 2.1 of the License, or (at your
+# option) any later version.
+#
+# logilab-astng is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+# for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with logilab-astng. If not, see <http://www.gnu.org/licenses/>.
+import sys
+
+from logilab.common.testlib import TestCase, unittest_main
+
+from logilab.astng.node_classes import Assign
+from logilab.astng.manager import ASTNGManager
+from logilab.astng.builder import ASTNGBuilder
+
+
+class Python3TC(TestCase):
+ def setUp(self):
+ self.manager = ASTNGManager()
+ self.builder = ASTNGBuilder(self.manager)
+ self.manager.astng_cache.clear()
+
+ def test_starred_notation(self):
+ if sys.version_info < (3, 0):
+ self.skipTest("test python 3k specific")
+ astng = self.builder.string_build("*a, b = [1, 2, 3]", 'test', 'test')
+
+ # Get the star node
+ node = next(next(next(astng.get_children()).get_children()).get_children())
+
+ self.assertTrue(isinstance(node.ass_type(), Assign))
+
+if __name__ == '__main__':
+ unittest_main()