diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-03 15:26:33 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-03 15:26:33 +0300 |
commit | 8ffc0c7a67532a5e51ad19aa8c93edd9abf4a2dc (patch) | |
tree | d4950525a9240967c3dc05a5e28fed2fa451f056 | |
parent | 933bad8f80b564bdff4e4450ed1f412d22ef8206 (diff) | |
download | astroid-8ffc0c7a67532a5e51ad19aa8c93edd9abf4a2dc.tar.gz |
Add a test for issue #188, which was triggered because the transforms weren't executed in a separated step. Closes issue #188.
-rw-r--r-- | astroid/tests/unittest_transforms.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/astroid/tests/unittest_transforms.py b/astroid/tests/unittest_transforms.py index 9c1e806..29a8b8d 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()
|