From 9b3cd652e1aba62ba4265b315c70eaed019caebe Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sun, 12 Feb 2012 18:30:01 +0100 Subject: [PATCH] Improve dir( GithubObject ) --- github/GithubObject.UnitTest.py | 2 ++ github/GithubObject.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/github/GithubObject.UnitTest.py b/github/GithubObject.UnitTest.py index d0069973..c96aa903 100644 --- a/github/GithubObject.UnitTest.py +++ b/github/GithubObject.UnitTest.py @@ -38,6 +38,8 @@ class GithubObjectWithOnlySimpleScalarAttributes( TestCaseWithGithubTestObject ) SimpleScalarAttributes( "a1", "a2", "a3", "a4" ) ) + def testInterface( self ): + self.assertEqual( [ e for e in dir( self.o ) if not e.startswith( "_" ) ], [ "a1", "a2", "a3", "a4" ] ) def testCompletion( self ): # A GithubObject: diff --git a/github/GithubObject.py b/github/GithubObject.py index ff252579..f7ccd728 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -135,6 +135,9 @@ def GithubObject( className, *attributePolicies ): else: self.__attributes[ attributeName ] = attributeDefinition.getValueFromRawValue( self, attributeValue ) + def __dir__( self ): + return attributeDefinitions.keys() + def __fetchAttribute( self, attributeName ): attributeDefinition = attributeDefinitions[ attributeName ] attributeDefinition.updateAttributes( self )