From 51bf7cbe8216d9a1da723c59b6feece0b1a34589 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Sun, 25 Sep 2016 18:08:16 +0200 Subject: win: GC.collect on all TC.tearDown to fix appveyor hang runs + Fixed the hangs at `test_git:TestGit.test_handle_process_output()`. [travisci skip] --- git/test/lib/helper.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 8be2881c..9488005f 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -299,6 +299,8 @@ class TestBase(TestCase): Dynamically add a read-only repository to our actual type. This way each test type has its own repository """ + import gc + gc.collect() cls.rorepo = Repo(GIT_REPO) @classmethod -- cgit v1.2.1 From 45f8f20bdf1447fbfebd19a07412d337626ed6b0 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 26 Sep 2016 19:42:42 +0200 Subject: Win, #519: FIX WinHangs: Popen() CREATE_NEW_PROCESS_GROUP to allow kill + FIXED most hangs BUT no more `git-daemon` un-killable! + Use logger for utils to replace stray print(). --- git/test/lib/helper.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 9488005f..b59f518b 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -5,12 +5,12 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php from __future__ import print_function import os -import sys from unittest import TestCase import time import tempfile import shutil import io +import logging from git import Repo, Remote, GitCommandError, Git from git.compat import string_types @@ -25,6 +25,8 @@ __all__ = ( 'with_rw_repo', 'with_rw_and_rw_remote_repo', 'TestBase', 'TestCase', 'GIT_REPO', 'GIT_DAEMON_PORT' ) +log = logging.getLogger('git.util') + #{ Routines @@ -120,7 +122,7 @@ def with_rw_repo(working_tree_ref, bare=False): try: return func(self, rw_repo) except: - print("Keeping repo after failure: %s" % repo_dir, file=sys.stderr) + log.info("Keeping repo after failure: %s", repo_dir) repo_dir = None raise finally: @@ -218,7 +220,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): # on some platforms ? if gd is not None: os.kill(gd.proc.pid, 15) - print(str(e)) + log.warning('git-ls-remote failed due to: %s(%s)', type(e), e) if os.name == 'nt': msg = "git-daemon needs to run this test, but windows does not have one. " msg += 'Otherwise, run: git-daemon "%s"' % temp_dir @@ -239,8 +241,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref): try: return func(self, rw_repo, rw_remote_repo) except: - print("Keeping repos after failure: repo_dir = %s, remote_repo_dir = %s" - % (repo_dir, remote_repo_dir), file=sys.stderr) + log.info("Keeping repos after failure: repo_dir = %s, remote_repo_dir = %s", + repo_dir, remote_repo_dir) repo_dir = remote_repo_dir = None raise finally: -- cgit v1.2.1 From 29eb301700c41f0af7d57d923ad069cbdf636381 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 26 Sep 2016 19:44:35 +0200 Subject: win, #519: proc.terminate() instead of kill(SIGTERM) + test_diff: replace asserts with unittest-asserts. --- git/test/lib/helper.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index b59f518b..75d4e6fb 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -219,7 +219,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): # Of course we expect it to work here already, but maybe there are timing constraints # on some platforms ? if gd is not None: - os.kill(gd.proc.pid, 15) + gd.proc.terminate() log.warning('git-ls-remote failed due to: %s(%s)', type(e), e) if os.name == 'nt': msg = "git-daemon needs to run this test, but windows does not have one. " @@ -246,9 +246,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref): repo_dir = remote_repo_dir = None raise finally: - # gd.proc.kill() ... no idea why that doesn't work if gd is not None: - os.kill(gd.proc.pid, 15) + gd.proc.terminate() os.chdir(prev_cwd) rw_repo.git.clear_cache() -- cgit v1.2.1 From f495e94028bfddc264727ffc464cd694ddd05ab8 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 26 Sep 2016 20:41:41 +0200 Subject: src, #519: collect all is_() calls --- git/test/lib/helper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 75d4e6fb..7cc1dcae 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -13,7 +13,7 @@ import io import logging from git import Repo, Remote, GitCommandError, Git -from git.compat import string_types +from git.compat import string_types, is_win osp = os.path.dirname @@ -73,7 +73,7 @@ def _mktemp(*args): prefixing /private/ will lead to incorrect paths on OSX.""" tdir = tempfile.mktemp(*args) # See :note: above to learn why this is comented out. - # if sys.platform == 'darwin': + # if is_darwin(): # tdir = '/private' + tdir return tdir @@ -83,7 +83,7 @@ def _rmtree_onerror(osremove, fullpath, exec_info): Handle the case on windows that read-only files cannot be deleted by os.remove by setting it to mode 777, then retry deletion. """ - if os.name != 'nt' or osremove is not os.remove: + if is_win() or osremove is not os.remove: raise os.chmod(fullpath, 0o777) @@ -221,7 +221,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): if gd is not None: gd.proc.terminate() log.warning('git-ls-remote failed due to: %s(%s)', type(e), e) - if os.name == 'nt': + if is_win(): msg = "git-daemon needs to run this test, but windows does not have one. " msg += 'Otherwise, run: git-daemon "%s"' % temp_dir raise AssertionError(msg) -- cgit v1.2.1 From aa3f2fa76844e1700ba37723acf603428b20ef74 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 26 Sep 2016 21:31:21 +0200 Subject: src, #519: Improve daemon launch so Win does not stuck + Retrofit try...finally blocks to ensure killing the daemon - now vulnerable also on Windows due to Popen() + CREATE_NEW_PROCESS_GROUP - BUT `test_base.test_with_rw_remote_and_rw_repo()` TC fails in MINGW due to invalid remote-URL in fetching-repo's config. Another day. - NEXT FREEZE to solve: test-diff_interface() under MINGW! --- git/test/lib/helper.py | 69 +++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 31 deletions(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 7cc1dcae..9e6be3e3 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -14,6 +14,7 @@ import logging from git import Repo, Remote, GitCommandError, Git from git.compat import string_types, is_win +import textwrap osp = os.path.dirname @@ -201,43 +202,45 @@ def with_rw_and_rw_remote_repo(working_tree_ref): d_remote.config_writer.set('url', remote_repo_url) temp_dir = osp(_mktemp()) - # On windows, this will fail ... we deal with failures anyway and default to telling the user to do it + # On MINGW-git, daemon exists, in Cygwin-git, this will fail. + gd = Git().daemon(temp_dir, enable='receive-pack', listen='127.0.0.1', port=GIT_DAEMON_PORT, + as_process=True) try: - gd = Git().daemon(temp_dir, enable='receive-pack', listen='127.0.0.1', port=GIT_DAEMON_PORT, - as_process=True) # yes, I know ... fortunately, this is always going to work if sleep time is just large enough time.sleep(0.5) - except Exception: - gd = None # end - # try to list remotes to diagnoes whether the server is up - try: - rw_repo.git.ls_remote(d_remote) - except GitCommandError as e: - # We assume in good faith that we didn't start the daemon - but make sure we kill it anyway - # Of course we expect it to work here already, but maybe there are timing constraints - # on some platforms ? - if gd is not None: - gd.proc.terminate() - log.warning('git-ls-remote failed due to: %s(%s)', type(e), e) - if is_win(): - msg = "git-daemon needs to run this test, but windows does not have one. " - msg += 'Otherwise, run: git-daemon "%s"' % temp_dir - raise AssertionError(msg) - else: - msg = 'Please start a git-daemon to run this test, execute: git daemon --enable=receive-pack "%s"' - msg += 'You can also run the daemon on a different port by passing --port=' - msg += 'and setting the environment variable GIT_PYTHON_TEST_GIT_DAEMON_PORT to ' - msg %= temp_dir + # try to list remotes to diagnoes whether the server is up + try: + rw_repo.git.ls_remote(d_remote) + except GitCommandError as e: + # We assume in good faith that we didn't start the daemon - but make sure we kill it anyway + # Of course we expect it to work here already, but maybe there are timing constraints + # on some platforms ? + if gd is not None: + gd.proc.terminate() + log.warning('git(%s) ls-remote failed due to:%s', + rw_repo.git_dir, e) + if is_win(): + msg = textwrap.dedent(""" + MINGW yet has problems with paths, CYGWIN additionally is missing `git-daemon` + needed to run this test. Anyhow, try starting `git-daemon` manually:""") + else: + msg = "Please try starting `git-daemon` manually:" + + msg += textwrap.dedent(""" + git daemon --enable=receive-pack '%s' + You can also run the daemon on a different port by passing --port=" + and setting the environment variable GIT_PYTHON_TEST_GIT_DAEMON_PORT to + """ % temp_dir) raise AssertionError(msg) - # END make assertion - # END catch ls remote error + # END make assertion + # END catch ls remote error + + # adjust working dir + prev_cwd = os.getcwd() + os.chdir(rw_repo.working_dir) - # adjust working dir - prev_cwd = os.getcwd() - os.chdir(rw_repo.working_dir) - try: try: return func(self, rw_repo, rw_remote_repo) except: @@ -245,11 +248,15 @@ def with_rw_and_rw_remote_repo(working_tree_ref): repo_dir, remote_repo_dir) repo_dir = remote_repo_dir = None raise + finally: + os.chdir(prev_cwd) + finally: if gd is not None: gd.proc.terminate() - os.chdir(prev_cwd) + import gc + gc.collect() rw_repo.git.clear_cache() rw_remote_repo.git.clear_cache() if repo_dir: -- cgit v1.2.1 From 618e6259ef03a4b25415bae31a7540ac5eb2e38a Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 26 Sep 2016 22:20:33 +0200 Subject: test, #519: Try appveyor advice for never-ending builds + see http://help.appveyor.com/discussions/problems/5334-nosetests-finsih-bu-build-stuck-and-next-job-dealys-to-start + Use `io.DEFAULT_BUFFER_SIZE`. + test_commit: replace asserts with unittest-asserts. - TRY Popen() NO universal_newlines: NO, reverted in next commits. + [travisci skip] --- git/test/lib/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 9e6be3e3..d92d76e2 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -253,7 +253,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): finally: if gd is not None: - gd.proc.terminate() + gd.proc.kill() import gc gc.collect() -- cgit v1.2.1 From c572a8d95d8fa184eb58b15b7ff96d01ef1f9ec3 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Tue, 27 Sep 2016 00:09:20 +0200 Subject: Win, #519: FIX undead Git-daemon on Windows + On MINGW-git, daemon exists but if invoked as 'git daemon', DAEMON CANNOT DIE! + So, launch `git-daemon` on Apveyor, but - remote TCs fail due to paths problems. + Updated README instructions on Windows. + Restore disabled remote TCs on Windows. + Disable failures on daemon-tests only the last moment (raise SkipTest) so when ready, it will also pass. --- git/test/lib/helper.py | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index d92d76e2..0a845a3f 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -140,6 +140,28 @@ def with_rw_repo(working_tree_ref, bare=False): return argument_passer +def launch_git_daemon(temp_dir, ip, port): + if is_win(): + ## On MINGW-git, daemon exists in .\Git\mingw64\libexec\git-core\, + # but if invoked as 'git daemon', it detaches from parent `git` cmd, + # and then CANNOT DIE! + # So, invoke it as a single command. + ## Cygwin-git has no daemon. + # + daemon_cmd = ['git-daemon', temp_dir, + '--enable=receive-pack', + '--listen=%s' % ip, + '--port=%s' % port] + gd = Git().execute(daemon_cmd, as_process=True) + else: + gd = Git().daemon(temp_dir, + enable='receive-pack', + listen=ip, + port=port, + as_process=True) + return gd + + def with_rw_and_rw_remote_repo(working_tree_ref): """ Same as with_rw_repo, but also provides a writable remote repository from which the @@ -167,6 +189,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): assert isinstance(working_tree_ref, string_types), "Decorator requires ref name for working tree checkout" def argument_passer(func): + def remote_repo_creator(self): remote_repo_dir = _mktemp("remote_repo_%s" % func.__name__) repo_dir = _mktemp("remote_clone_non_bare_repo") @@ -202,9 +225,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): d_remote.config_writer.set('url', remote_repo_url) temp_dir = osp(_mktemp()) - # On MINGW-git, daemon exists, in Cygwin-git, this will fail. - gd = Git().daemon(temp_dir, enable='receive-pack', listen='127.0.0.1', port=GIT_DAEMON_PORT, - as_process=True) + gd = launch_git_daemon(temp_dir, '127.0.0.1', GIT_DAEMON_PORT) try: # yes, I know ... fortunately, this is always going to work if sleep time is just large enough time.sleep(0.5) @@ -223,8 +244,10 @@ def with_rw_and_rw_remote_repo(working_tree_ref): rw_repo.git_dir, e) if is_win(): msg = textwrap.dedent(""" - MINGW yet has problems with paths, CYGWIN additionally is missing `git-daemon` - needed to run this test. Anyhow, try starting `git-daemon` manually:""") + MINGW yet has problems with paths, and `git-daemon.exe` must be in PATH + (look into .\Git\mingw64\libexec\git-core\); + CYGWIN has no daemon, but if one exists, it gets along fine (has also paths problems) + Anyhow, alternatively try starting `git-daemon` manually:""") else: msg = "Please try starting `git-daemon` manually:" @@ -233,7 +256,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref): You can also run the daemon on a different port by passing --port=" and setting the environment variable GIT_PYTHON_TEST_GIT_DAEMON_PORT to """ % temp_dir) - raise AssertionError(msg) + from nose import SkipTest + raise SkipTest(msg) if is_win else AssertionError(msg) # END make assertion # END catch ls remote error -- cgit v1.2.1 From e61439b3018b0b9a8eb43e59d0d7cf32041e2fed Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Tue, 27 Sep 2016 16:05:58 +0200 Subject: src: constify is_() calls + TCs: unittest-asserts for git-tests. --- git/test/lib/helper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 0a845a3f..7f4e81e0 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -74,7 +74,7 @@ def _mktemp(*args): prefixing /private/ will lead to incorrect paths on OSX.""" tdir = tempfile.mktemp(*args) # See :note: above to learn why this is comented out. - # if is_darwin(): + # if is_darwin: # tdir = '/private' + tdir return tdir @@ -84,7 +84,7 @@ def _rmtree_onerror(osremove, fullpath, exec_info): Handle the case on windows that read-only files cannot be deleted by os.remove by setting it to mode 777, then retry deletion. """ - if is_win() or osremove is not os.remove: + if is_win or osremove is not os.remove: raise os.chmod(fullpath, 0o777) @@ -141,7 +141,7 @@ def with_rw_repo(working_tree_ref, bare=False): def launch_git_daemon(temp_dir, ip, port): - if is_win(): + if is_win: ## On MINGW-git, daemon exists in .\Git\mingw64\libexec\git-core\, # but if invoked as 'git daemon', it detaches from parent `git` cmd, # and then CANNOT DIE! @@ -242,7 +242,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): gd.proc.terminate() log.warning('git(%s) ls-remote failed due to:%s', rw_repo.git_dir, e) - if is_win(): + if is_win: msg = textwrap.dedent(""" MINGW yet has problems with paths, and `git-daemon.exe` must be in PATH (look into .\Git\mingw64\libexec\git-core\); -- cgit v1.2.1 From 137ee6ef22c4e6480f95972ef220d1832cdc709a Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Tue, 27 Sep 2016 22:07:19 +0200 Subject: Win, #519: FIX with_rw_directory() to remove read-only dirs + Stop using gitdb's respective helper. + Fix files chmod(555) which CANNOT DELETE on Windows (but do on Linux). --- git/test/lib/helper.py | 53 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 16 deletions(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 7f4e81e0..6d840027 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -4,15 +4,16 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php from __future__ import print_function + import os from unittest import TestCase import time import tempfile -import shutil import io import logging from git import Repo, Remote, GitCommandError, Git +from git.util import rmtree from git.compat import string_types, is_win import textwrap @@ -23,7 +24,8 @@ GIT_DAEMON_PORT = os.environ.get("GIT_PYTHON_TEST_GIT_DAEMON_PORT", "9418") __all__ = ( 'fixture_path', 'fixture', 'absolute_project_path', 'StringProcessAdapter', - 'with_rw_repo', 'with_rw_and_rw_remote_repo', 'TestBase', 'TestCase', 'GIT_REPO', 'GIT_DAEMON_PORT' + 'with_rw_directory', 'with_rw_repo', 'with_rw_and_rw_remote_repo', 'TestBase', 'TestCase', + 'GIT_REPO', 'GIT_DAEMON_PORT' ) log = logging.getLogger('git.util') @@ -79,16 +81,31 @@ def _mktemp(*args): return tdir -def _rmtree_onerror(osremove, fullpath, exec_info): - """ - Handle the case on windows that read-only files cannot be deleted by - os.remove by setting it to mode 777, then retry deletion. - """ - if is_win or osremove is not os.remove: - raise +def with_rw_directory(func): + """Create a temporary directory which can be written to, remove it if the + test succeeds, but leave it otherwise to aid additional debugging""" - os.chmod(fullpath, 0o777) - os.remove(fullpath) + def wrapper(self): + path = tempfile.mktemp(prefix=func.__name__) + os.mkdir(path) + keep = False + try: + try: + return func(self, path) + except Exception: + log.info.write("Test %s.%s failed, output is at %r\n", + type(self).__name__, func.__name__, path) + keep = True + raise + finally: + # Need to collect here to be sure all handles have been closed. It appears + # a windows-only issue. In fact things should be deleted, as well as + # memory maps closed, once objects go out of scope. For some reason + # though this is not the case here unless we collect explicitly. + import gc + gc.collect() + if not keep: + rmtree(path) def with_rw_repo(working_tree_ref, bare=False): @@ -129,8 +146,11 @@ def with_rw_repo(working_tree_ref, bare=False): finally: os.chdir(prev_cwd) rw_repo.git.clear_cache() + rw_repo = None + import gc + gc.collect() if repo_dir is not None: - shutil.rmtree(repo_dir, onerror=_rmtree_onerror) + rmtree(repo_dir) # END rm test repo if possible # END cleanup # END rw repo creator @@ -279,14 +299,15 @@ def with_rw_and_rw_remote_repo(working_tree_ref): if gd is not None: gd.proc.kill() - import gc - gc.collect() rw_repo.git.clear_cache() rw_remote_repo.git.clear_cache() + rw_repo = rw_remote_repo = None + import gc + gc.collect() if repo_dir: - shutil.rmtree(repo_dir, onerror=_rmtree_onerror) + rmtree(repo_dir) if remote_repo_dir: - shutil.rmtree(remote_repo_dir, onerror=_rmtree_onerror) + rmtree(remote_repo_dir) if gd is not None: gd.proc.wait() -- cgit v1.2.1 From f11fdf1d9d22a198511b02f3ca90146cfa5deb5c Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Wed, 28 Sep 2016 14:43:47 +0200 Subject: remote, #519: FIX1-of-2 double-decoding push-infos + When `universal_lines==True` (515a6b9ccf8) must tel `handle_process_output` to stop decoding strings. --- git/test/lib/helper.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 6d840027..949e474f 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -258,8 +258,10 @@ def with_rw_and_rw_remote_repo(working_tree_ref): # We assume in good faith that we didn't start the daemon - but make sure we kill it anyway # Of course we expect it to work here already, but maybe there are timing constraints # on some platforms ? - if gd is not None: + try: gd.proc.terminate() + except Exception as ex: + log.debug("Ignoring %r while terminating proc after %r.", ex, e) log.warning('git(%s) ls-remote failed due to:%s', rw_repo.git_dir, e) if is_win: @@ -296,8 +298,10 @@ def with_rw_and_rw_remote_repo(working_tree_ref): os.chdir(prev_cwd) finally: - if gd is not None: + try: gd.proc.kill() + except: + pass ## Either it has died (and we're here), or it won't die, again here... rw_repo.git.clear_cache() rw_remote_repo.git.clear_cache() -- cgit v1.2.1 From 6e98416791566f44a407dcac07a1e1f1b0483544 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Wed, 28 Sep 2016 17:10:59 +0200 Subject: remote, #519: INCOMPLETE FIX-2 double-decoding push-infos + Unicode PY2/3 issues fixed also in pump stream func. --- git/test/lib/helper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 949e474f..90d2b1e9 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -301,7 +301,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref): try: gd.proc.kill() except: - pass ## Either it has died (and we're here), or it won't die, again here... + ## Either it has died (and we're here), or it won't die, again here... + pass rw_repo.git.clear_cache() rw_remote_repo.git.clear_cache() -- cgit v1.2.1 From 9a521681ff8614beb8e2c566cf3c475baca22169 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Sat, 1 Oct 2016 18:20:13 +0200 Subject: io, #519: ALL open() --> with open() + Some cases had restructuring of code. --- git/test/lib/helper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 90d2b1e9..a85ac2fd 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -39,7 +39,8 @@ def fixture_path(name): def fixture(name): - return open(fixture_path(name), 'rb').read() + with open(fixture_path(name), 'rb') as fd: + return fd.read() def absolute_project_path(): @@ -373,7 +374,6 @@ class TestBase(TestCase): """ repo = repo or self.rorepo abs_path = os.path.join(repo.working_tree_dir, rela_path) - fp = open(abs_path, "w") - fp.write(data) - fp.close() + with open(abs_path, "w") as fp: + fp.write(data) return abs_path -- cgit v1.2.1