From d7729245060f9aecfef4544f91e2656aa8d483ec Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sat, 7 Feb 2015 11:14:03 -0500 Subject: ENH: respect GIT_PYTHON_TEST_GIT_REPO_BASE env var in tests --- git/test/lib/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 8300f272..5efb7d9d 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -15,7 +15,7 @@ import io from git import Repo, Remote, GitCommandError, Git from git.compat import string_types -GIT_REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) +GIT_REPO = os.environ.get("GIT_PYTHON_TEST_GIT_REPO_BASE", os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))) __all__ = ( 'fixture_path', 'fixture', 'absolute_project_path', 'StringProcessAdapter', -- cgit v1.2.3 From 756b7ad43d0ad18858075f90ce5eaec2896d439c Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sat, 7 Feb 2015 11:14:42 -0500 Subject: BF: skip unicode filename test in env not supporting unicode encodings --- git/test/test_base.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'git') diff --git a/git/test/test_base.py b/git/test/test_base.py index 91b9d005..72f2d554 100644 --- a/git/test/test_base.py +++ b/git/test/test_base.py @@ -5,6 +5,7 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php import os +import sys import tempfile import git.objects.base as base @@ -116,6 +117,14 @@ class TestBase(TestBase): filename = u"שלום.txt" file_path = os.path.join(rw_repo.working_dir, filename) + + # verify first that we could encode file name in this environment + try: + _ = file_path.encode(sys.getfilesystemencoding()) + except UnicodeEncodeError: + from nose import SkipTest + raise SkipTest("Environment doesn't support unicode filenames") + open(file_path, "wb").write(b'something') if os.name == 'nt': -- cgit v1.2.3 From fe426d404b727d0567f21871f61cc6dc881e8bf0 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 9 Feb 2015 19:22:18 +0100 Subject: Minor Flake8 fixes. Latest version of it is required to show the issues travis shows as well --- git/index/fun.py | 6 +++--- git/test/lib/helper.py | 10 ++++++---- git/test/test_base.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'git') diff --git a/git/index/fun.py b/git/index/fun.py index f07cf7dc..f8bd9d89 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -10,8 +10,6 @@ from stat import ( S_IFREG, ) -S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule - from io import BytesIO import os import subprocess @@ -33,7 +31,6 @@ from .typ import ( CE_NAMEMASK, CE_STAGESHIFT ) -CE_NAMEMASK_INV = ~CE_NAMEMASK from .util import ( pack, @@ -47,6 +44,9 @@ from git.compat import ( force_text ) +S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule +CE_NAMEMASK_INV = ~CE_NAMEMASK + __all__ = ('write_cache', 'read_cache', 'write_tree_from_cache', 'entry_key', 'stat_mode_to_index_mode', 'S_IFGITLINK', 'run_commit_hook', 'hook_path') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 5efb7d9d..31bee78f 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -15,7 +15,9 @@ import io from git import Repo, Remote, GitCommandError, Git from git.compat import string_types -GIT_REPO = os.environ.get("GIT_PYTHON_TEST_GIT_REPO_BASE", os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))) +osp = os.path.dirname + +GIT_REPO = os.environ.get("GIT_PYTHON_TEST_GIT_REPO_BASE", osp(osp(osp(osp(__file__))))) __all__ = ( 'fixture_path', 'fixture', 'absolute_project_path', 'StringProcessAdapter', @@ -26,7 +28,7 @@ __all__ = ( def fixture_path(name): - test_dir = os.path.dirname(os.path.dirname(__file__)) + test_dir = osp(osp(__file__)) return os.path.join(test_dir, "fixtures", name) @@ -35,7 +37,7 @@ def fixture(name): def absolute_project_path(): - return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) + return os.path.abspath(os.path.join(osp(__file__), "..", "..")) #} END routines @@ -195,7 +197,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): d_remote.config_writer.set('url', remote_repo_url) - temp_dir = os.path.dirname(_mktemp()) + temp_dir = osp(_mktemp()) # On windows, this will fail ... we deal with failures anyway and default to telling the user to do it try: gd = Git().daemon(temp_dir, enable='receive-pack', as_process=True) diff --git a/git/test/test_base.py b/git/test/test_base.py index 72f2d554..94379ca3 100644 --- a/git/test/test_base.py +++ b/git/test/test_base.py @@ -120,7 +120,7 @@ class TestBase(TestBase): # verify first that we could encode file name in this environment try: - _ = file_path.encode(sys.getfilesystemencoding()) + file_path.encode(sys.getfilesystemencoding()) except UnicodeEncodeError: from nose import SkipTest raise SkipTest("Environment doesn't support unicode filenames") -- cgit v1.2.3