| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,8 +5,6 @@ | |||
| 5 | 5 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 6 | 6 | ||
| 7 | 7 | import contextlib | |
| 8 | - import re | ||
| 9 | - | ||
| 10 | 8 | import io | |
| 11 | 9 | import logging | |
| 12 | 10 | import os | |
@@ -21,7 +19,7 @@ | |||
| 21 | 19 | import threading | |
| 22 | 20 | from collections import OrderedDict | |
| 23 | 21 | from textwrap import dedent | |
| 24 | - import unittest.mock | ||
| 22 | + import mock | ||
| 25 | 23 | ||
| 26 | 24 | from git.compat import ( | |
| 27 | 25 | string_types, | |
@@ -62,6 +60,11 @@ | |||
| 62 | 60 | __all__ = ('Git',) | |
| 63 | 61 | ||
| 64 | 62 | ||
| 63 | + @contextlib.contextmanager | ||
| 64 | + def nullcontext(enter_result=None): | ||
| 65 | + yield enter_result | ||
| 66 | + | ||
| 67 | + | ||
| 65 | 68 | # ============================================================================== | |
| 66 | 69 | ## @name Utilities | |
| 67 | 70 | # ------------------------------------------------------------------------------ | |
@@ -756,7 +759,7 @@ def execute(self, command, | |||
| 756 | 759 | cmd_not_found_exception = FileNotFoundError # NOQA # exists, flake8 unknown @UndefinedVariable | |
| 757 | 760 | else: | |
| 758 | 761 | cmd_not_found_exception = OSError | |
| 759 | - patch_caller_env = contextlib.nullcontext() | ||
| 762 | + patch_caller_env = nullcontext() | ||
| 760 | 763 | # end handle | |
| 761 | 764 | ||
| 762 | 765 | stdout_sink = (PIPE | |
@@ -781,7 +784,7 @@ def execute(self, command, | |||
| 781 | 784 | close_fds=is_posix, # unsupported on windows | |
| 782 | 785 | universal_newlines=universal_newlines, | |
| 783 | 786 | creationflags=PROC_CREATIONFLAGS, | |
| 784 | - **subprocess_kwargs, | ||
| 787 | + **subprocess_kwargs | ||
| 785 | 788 | ) | |
| 786 | 789 | except cmd_not_found_exception as err: | |
| 787 | 790 | raise GitCommandNotFound(command, err) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,12 +4,16 @@ | |||
| 4 | 4 | # | |
| 5 | 5 | # This module is part of GitPython and is released under | |
| 6 | 6 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 7 | + from __future__ import print_function | ||
| 8 | + | ||
| 7 | 9 | import contextlib | |
| 8 | 10 | import os | |
| 9 | 11 | import shutil | |
| 10 | 12 | import subprocess | |
| 11 | 13 | import sys | |
| 12 | - from tempfile import TemporaryDirectory, TemporaryFile | ||
| 14 | + from tempfile import TemporaryFile | ||
| 15 | + from backports.tempfile import TemporaryDirectory | ||
| 16 | + import six | ||
| 13 | 17 | ||
| 14 | 18 | from git import ( | |
| 15 | 19 | Git, | |
@@ -122,12 +126,13 @@ def test_it_executes_git_not_from_cwd(self): | |||
| 122 | 126 | else: | |
| 123 | 127 | # Create a shell script that doesn't do anything. | |
| 124 | 128 | impostor_path = os.path.join(tmpdir, "git") | |
| 125 | - with open(impostor_path, mode="w", encoding="utf-8") as file: | ||
| 129 | + with open(impostor_path, mode="w") as file: | ||
| 126 | 130 | print("#!/bin/sh", file=file) | |
| 127 | 131 | os.chmod(impostor_path, 0o755) | |
| 128 | 132 | ||
| 129 | 133 | with _chdir(tmpdir): | |
| 130 | - self.assertRegex(self.git.execute(["git", "version"]), r"^git version\b") | ||
| 134 | + # six.assertRegex(self.git.execute(["git", "version"]).encode("UTF-8"), r"^git version\b") | ||
| 135 | + self.assertRegexpMatches(self.git.execute(["git", "version"]), r"^git version\b") | ||
| 131 | 136 | ||
| 132 | 137 | def test_it_accepts_stdin(self): | |
| 133 | 138 | filename = fixture_path("cat_file_blob") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1 +1,2 @@ | |||
| 1 | 1 | gitdb2>=2,<3 | |
| 2 | + mock | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,5 +4,5 @@ coverage | |||
| 4 | 4 | flake8 | |
| 5 | 5 | nose | |
| 6 | 6 | tox | |
| 7 | - mock; python_version=='2.7' | ||
| 8 | - pathlib2; python_version=='2.7' | ||
| 7 | + backports.tempfile | ||
| 8 | + six | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments