Exemplo n.º 1
0
 def setup_method(self, method):
     # Basic logging configuration so if a test fails we can see
     # the statements at WARN or ERROR at least.
     logging.basicConfig()
     self.method = method.__name__
     self.cwd = os.getcwd()
     self.token = get_token_or_user(local=False)
     self.gh = get_github(self.token, dont_ask=True)
     self.user = self.gh.get_login()
     self.path = tempfile.mkdtemp("", "sandbox-", ".")
     self.path = os.path.abspath(self.path)
     try:
         with open(os.devnull, 'w') as dev_null:
             p = Popen(["git", "clone", "-q", sandbox_url, self.path],
                       stdout=dev_null,
                       stderr=dev_null)
             assert p.wait() == 0
         self.sandbox = self.gh.git_repo(self.path)
         self.origin_remote = "origin"
     except:
         try:
             shutil.rmtree(self.path)
         finally:
             # Return to cwd regardless.
             os.chdir(self.cwd)
         raise
     # If we succeed, then we change to this dir.
     os.chdir(self.path)
Exemplo n.º 2
0
 def setup_method(self, method):
     # Basic logging configuration so if a test fails we can see
     # the statements at WARN or ERROR at least.
     logging.basicConfig()
     self.method = method.__name__
     self.cwd = os.getcwd()
     self.token = get_token_or_user(local=False)
     self.gh = get_github(self.token, dont_ask=True)
     self.user = self.gh.get_login()
     self.path = tempfile.mkdtemp("", "sandbox-", ".")
     self.path = os.path.abspath(self.path)
     try:
         with open(os.devnull, 'w') as dev_null:
             p = Popen(["git", "clone", "-q", sandbox_url, self.path],
                       stdout=dev_null, stderr=dev_null)
             assert p.wait() == 0
         self.sandbox = self.gh.git_repo(self.path)
         self.origin_remote = "origin"
     except Exception:
         try:
             shutil.rmtree(self.path)
         finally:
             # Return to cwd regardless.
             os.chdir(self.cwd)
         raise
     # If we succeed, then we change to this dir.
     os.chdir(self.path)
Exemplo n.º 3
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.cwd = os.getcwd()
     self.token = get_token_or_user(local=False)
     self.gh = get_github(self.token, dont_ask=True)
     self.user = self.gh.get_login()
     self.path = tempfile.mkdtemp("", "sandbox-", ".")
     self.path = os.path.abspath(self.path)
     try:
         p = Popen(["git", "clone", sandbox_url, self.path],
                   stdout=PIPE, stderr=PIPE)
         self.assertEquals(0, p.wait())
         self.sandbox = self.gh.git_repo(self.path)
     except:
         try:
             shutil.rmtree(self.path)
         finally:
             # Return to cwd regardless.
             os.chdir(self.cwd)
         raise
     # If we succeed, then we change to this dir.
     os.chdir(self.path)
Exemplo n.º 4
0
 def testUserAndTokenConfig(self):
     uuid = self.uuid()
     self.writeConfigFile("[github]\n    user = 2\n    token = %s" % uuid)
     self.assertEquals(uuid, get_token_or_user(local=True))
Exemplo n.º 5
0
 def testEmptyConfig(self):
     self.assertEquals(None, get_token_or_user(local=True))
Exemplo n.º 6
0
 def testTokenConfig(self):
     uuid = self.uuid()
     self.writeConfigFile("[github]\n    token = %s" % uuid)
     assert get_token_or_user(local=True) == uuid
Exemplo n.º 7
0
 def testEmptyConfig(self):
     assert get_token_or_user(local=True) is None
Exemplo n.º 8
0
 def testUserAndTokenConfig(self):
     uuid = self.uuid()
     self.writeConfigFile("[github]\n    user = 2\n    token = %s" % uuid)
     assert get_token_or_user(local=True) == uuid
Exemplo n.º 9
0
 def testEmptyConfig(self):
     assert get_token_or_user(local=True) is None