diff options
author | Laszlo Pandy <git@laszlopandy.com> | 2011-01-11 21:41:47 +0100 |
---|---|---|
committer | Tomeu Vizoso <tomeu.vizoso@collabora.co.uk> | 2011-01-13 17:41:25 +0100 |
commit | c36fbf4918c8557a8e274a12004a412da3b22b2c (patch) | |
tree | c414d94071bc9231eeb24c0ccdf424e131860e4d /tests/test_everything.py | |
parent | 1679e6af3f212e4d4644e048dc3c6177ed3fac6b (diff) | |
download | pygobject-c36fbf4918c8557a8e274a12004a412da3b22b2c.tar.gz |
Fix the __dir__() methods on DynamicModule and IntrospectionModule
Previously the __dir__() methods did not list all attributes.
A simple test case is included. It does not test to see if
every attribute is listed, it just tests a few of each kind:
- (wrapped) typelib attributes
- class attributes and methods
- instance attributes
A set() is used to avoid returning duplicate attributes.
The test case checks for this as well.
https://bugzilla.gnome.org/show_bug.cgi?id=639229
Diffstat (limited to 'tests/test_everything.py')
-rw-r--r-- | tests/test_everything.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_everything.py b/tests/test_everything.py index f72a27c3..b2f24635 100644 --- a/tests/test_everything.py +++ b/tests/test_everything.py @@ -131,6 +131,24 @@ class TestEverything(unittest.TestCase): gtype = Everything.test_gtype(ARegisteredClass) self.assertEquals(ARegisteredClass.__gtype__, gtype) self.assertRaises(TypeError, Everything.test_gtype, 'ARegisteredClass') + + def test_dir(self): + attr_list = dir(Everything) + + # test that typelib attributes are listed + self.assertTrue('TestStructA' in attr_list) + + # test that class attributes and methods are listed + self.assertTrue('__class__' in attr_list) + self.assertTrue('__dir__' in attr_list) + self.assertTrue('__repr__' in attr_list) + + # test that instance members are listed + self.assertTrue('_namespace' in attr_list) + self.assertTrue('version' in attr_list) + + # test that there are no duplicates returned + self.assertEqual(len(attr_list), len(set(attr_list))) class TestNullableArgs(unittest.TestCase): def test_in_nullable_hash(self): |