From 2c04b8adbd91d38eef4f0767337ab7a12b2f684b Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sat, 26 May 2012 10:28:07 +0100 Subject: [PATCH] Allow test without pre-set-up Github --- test/Framework.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/Framework.py b/test/Framework.py index 1e16e57b..321cb02c 100644 --- a/test/Framework.py +++ b/test/Framework.py @@ -79,7 +79,7 @@ class ReplayingHttpsConnection: def close( self ): self.__file.readline() -class TestCase( unittest.TestCase ): +class BasicTestCase( unittest.TestCase ): recordMode = False def setUp( self ): @@ -87,12 +87,14 @@ class TestCase( unittest.TestCase ): self.__fileName = "" self.__file = None if self.recordMode: - import GithubCredentials httplib.HTTPSConnection = lambda *args, **kwds: RecordingHttpsConnection( self.__openFile( "w" ), *args, **kwds ) - self.g = github.Github( GithubCredentials.login, GithubCredentials.password ) + import GithubCredentials + self.login = GithubCredentials.login + self.password = GithubCredentials.password else: httplib.HTTPSConnection = lambda *args, **kwds: ReplayingHttpsConnection( self, self.__openFile( "r" ) ) - self.g = github.Github( "login", "password" ) + self.login = "login" + self.password = "password" def tearDown( self ): unittest.TestCase.tearDown( self ) @@ -114,6 +116,11 @@ class TestCase( unittest.TestCase ): self.assertEqual( self.__file.readline(), "" ) self.__file.close() +class TestCase( BasicTestCase ): + def setUp( self ): + BasicTestCase.setUp( self ) + self.g = github.Github( self.login, self.password ) + class TestCaseWithRepo( TestCase ): def setUp( self ): TestCase.setUp( self ) @@ -121,6 +128,6 @@ class TestCaseWithRepo( TestCase ): def main(): if "--record" in sys.argv: - TestCase.recordMode = True + BasicTestCase.recordMode = True unittest.main( argv = [ arg for arg in sys.argv if arg != "--record" ] )