summaryrefslogtreecommitdiff
path: root/astroid/tests/unittest_transforms.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-10-03 15:26:33 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2015-10-03 15:26:33 +0300
commit2ea4dfbdbad28b51ee51c9050af0dff025b62cef (patch)
tree6ab1810daf408dc0ef0e2bc69432ba6b871d0e68 /astroid/tests/unittest_transforms.py
parentb4d36f2b922509fd15f3fd37829495da2f2c92b6 (diff)
downloadastroid-git-2ea4dfbdbad28b51ee51c9050af0dff025b62cef.tar.gz
Add a test for issue #188, which was triggered because the transforms weren't executed in a separated step. Closes issue #188.
Diffstat (limited to 'astroid/tests/unittest_transforms.py')
-rw-r--r--astroid/tests/unittest_transforms.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/astroid/tests/unittest_transforms.py b/astroid/tests/unittest_transforms.py
index 9c1e8065..29a8b8db 100644
--- a/astroid/tests/unittest_transforms.py
+++ b/astroid/tests/unittest_transforms.py
@@ -215,6 +215,31 @@ class TestTransforms(unittest.TestCase):
# The transform wasn't applied.
self.assertIsInstance(module.body[0], nodes.FunctionDef)
+ def test_transform_crashes_on_is_subtype_of(self):
+ # Test that we don't crash when having is_subtype_of
+ # in a transform, as per issue #188. This happened
+ # before, when the transforms weren't in their own step.
+ def transform_class(cls):
+ if cls.is_subtype_of('django.db.models.base.Model'):
+ return cls
+ return cls
+
+ self.transformer.register_transform(nodes.ClassDef,
+ transform_class)
+
+ self.parse_transform('''
+ # Change environ to automatically call putenv() if it exists
+ import os
+ putenv = os.putenv
+ try:
+ # This will fail if there's no putenv
+ putenv
+ except NameError:
+ pass
+ else:
+ import UserDict
+ ''')
+
if __name__ == '__main__':
unittest.main()