diff --git a/github/Github.UnitTest.py b/github/Github.UnitTest.py index b36664f1..73d75064 100644 --- a/github/Github.UnitTest.py +++ b/github/Github.UnitTest.py @@ -7,9 +7,10 @@ class TestCase( unittest.TestCase ): def setUp( self ): unittest.TestCase.setUp( self ) - self.g = Github( "login", "password" ) - self.requester = MockMockMock.Mock( "requester" ) + self.debugFile = MockMockMock.Mock( "debugFile", self.requester ) + + self.g = Github( "login", "password", self.debugFile.object ) self.g._Github__requester = self.requester.object def tearDown( self ): @@ -109,4 +110,9 @@ class TestCase( unittest.TestCase ): self.requester.expect.dataRequest( "GET", "/repos/xxx/yyy/compare/foo...bar", None, None ).andReturn( { "gabu": "zomeuh" } ) self.assertEqual( self.g.get_user().get_repo( "yyy" ).compare( "foo", "bar" ), { "gabu": "zomeuh" } ) + def testDebugPrint( self ): + self.requester.expect.dataRequest( "GET", "/user", None, None ).andReturn( { "login": "xxx", "unknownAttribute": 42 } ) + self.debugFile.expect.write( "Missing definition of attribute unknownAttribute in class AuthenticatedUser\n" ) + self.g.get_user().location + unittest.main() diff --git a/github/Github.py b/github/Github.py index db5f6e57..e6373d6e 100644 --- a/github/Github.py +++ b/github/Github.py @@ -2,8 +2,9 @@ from Requester import Requester from GithubObjects import * class Github: - def __init__( self, login, password ): + def __init__( self, login, password, debugFile = None ): self.__requester = Requester( login, password ) + self.__debugFile = debugFile def _dataRequest( self, verb, url, parameters, data ): return self.__requester.dataRequest( verb, url, parameters, data ) @@ -29,3 +30,7 @@ class Github: for attributes in self._dataRequest( "GET", "/gists/public", None, None ) ] + + def _printDebug( self, *args ): + if self.__debugFile is not None: + self.__debugFile.write( " ".join( str( arg ) for arg in args ) + "\n" ) diff --git a/github/GithubObjects/GithubObject/GithubObject.py b/github/GithubObjects/GithubObject/GithubObject.py index f8b56fb8..72464749 100644 --- a/github/GithubObjects/GithubObject/GithubObject.py +++ b/github/GithubObjects/GithubObject/GithubObject.py @@ -88,7 +88,7 @@ def GithubObject( className, *attributePolicies ): attributeDefinition = GithubObject.__attributeDefinitions[ attributeName ] self.__attributes[ attributeName ] = attributeDefinition.getValueFromRawValue( self, attributeValue ) except KeyError: - pass + self._github._printDebug( "Missing definition of attribute", attributeName, "in class", className ) def _markAsCompleted( self ): for attributeName, attributeDefinition in GithubObject.__attributeDefinitions.iteritems():