From 9f9595da9edacfbd73c53dbb225974f8f392c6d4 Mon Sep 17 00:00:00 2001 From: Xavier Verges Date: Sun, 4 Oct 2020 20:46:01 +0200 Subject: [PATCH 1/2] Do not break convention when updating sys.path --- git/__init__.py | 2 +- test/test_installation.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/git/__init__.py b/git/__init__.py index 507307422..534408308 100644 --- a/git/__init__.py +++ b/git/__init__.py @@ -19,7 +19,7 @@ def _init_externals(): """Initialize external projects by putting them into the path""" if __version__ == 'git' and 'PYOXIDIZER' not in os.environ: - sys.path.insert(0, osp.join(osp.dirname(__file__), 'ext', 'gitdb')) + sys.path.insert(1, osp.join(osp.dirname(__file__), 'ext', 'gitdb')) try: import gitdb diff --git a/test/test_installation.py b/test/test_installation.py index db14bc846..3b39a3280 100644 --- a/test/test_installation.py +++ b/test/test_installation.py @@ -1,6 +1,7 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php +import ast import os import subprocess from test.lib import TestBase @@ -27,3 +28,8 @@ def test_installation(self, rw_dir): self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Can't build - setup.py failed") result = subprocess.run([self.python, '-c', 'import git'], stdout=subprocess.PIPE, cwd=self.sources) self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Selftest failed") + result = subprocess.run([self.python, '-c', 'import sys;import git; print(sys.path)'], stdout=subprocess.PIPE, cwd=self.sources) + syspath = result.stdout.decode('utf-8').splitlines()[0] + syspath = ast.literal_eval(syspath) + self.assertEqual('', syspath[0], msg='Failed to follow the conventions for https://docs.python.org/3/library/sys.html#sys.path') + self.assertTrue(syspath[1].endswith('gitdb'), msg='Failed to add gitdb to sys.path') From 55883c27cbcc53a56e808b8426963698ff9adb9c Mon Sep 17 00:00:00 2001 From: Xavier Verges Date: Sun, 4 Oct 2020 20:55:10 +0200 Subject: [PATCH 2/2] Keep flake happy --- test/test_installation.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/test_installation.py b/test/test_installation.py index 3b39a3280..6117be984 100644 --- a/test/test_installation.py +++ b/test/test_installation.py @@ -28,8 +28,10 @@ def test_installation(self, rw_dir): self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Can't build - setup.py failed") result = subprocess.run([self.python, '-c', 'import git'], stdout=subprocess.PIPE, cwd=self.sources) self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Selftest failed") - result = subprocess.run([self.python, '-c', 'import sys;import git; print(sys.path)'], stdout=subprocess.PIPE, cwd=self.sources) - syspath = result.stdout.decode('utf-8').splitlines()[0] + result = subprocess.run([self.python, '-c', 'import sys;import git; print(sys.path)'], + stdout=subprocess.PIPE, cwd=self.sources) + syspath = result.stdout.decode('utf-8').splitlines()[0] syspath = ast.literal_eval(syspath) - self.assertEqual('', syspath[0], msg='Failed to follow the conventions for https://docs.python.org/3/library/sys.html#sys.path') + self.assertEqual('', syspath[0], + msg='Failed to follow the conventions for https://docs.python.org/3/library/sys.html#sys.path') self.assertTrue(syspath[1].endswith('gitdb'), msg='Failed to add gitdb to sys.path')