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)
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)
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)