mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #1045 from pre-commit/fix_test_pre_commit_on_path
Fix test_environment_not_sourced when pre-commit is installed globally
This commit is contained in:
commit
099f521b7e
2 changed files with 12 additions and 5 deletions
|
|
@ -10,7 +10,7 @@ resources:
|
||||||
type: github
|
type: github
|
||||||
endpoint: github
|
endpoint: github
|
||||||
name: asottile/azure-pipeline-templates
|
name: asottile/azure-pipeline-templates
|
||||||
ref: refs/tags/v0.0.13
|
ref: refs/tags/v0.0.14
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- template: job--pre-commit.yml@asottile
|
- template: job--pre-commit.yml@asottile
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ from pre_commit.commands.install_uninstall import is_our_script
|
||||||
from pre_commit.commands.install_uninstall import PRIOR_HASHES
|
from pre_commit.commands.install_uninstall import PRIOR_HASHES
|
||||||
from pre_commit.commands.install_uninstall import shebang
|
from pre_commit.commands.install_uninstall import shebang
|
||||||
from pre_commit.commands.install_uninstall import uninstall
|
from pre_commit.commands.install_uninstall import uninstall
|
||||||
|
from pre_commit.parse_shebang import find_executable
|
||||||
from pre_commit.util import cmd_output
|
from pre_commit.util import cmd_output
|
||||||
from pre_commit.util import make_executable
|
from pre_commit.util import make_executable
|
||||||
from pre_commit.util import mkdirp
|
from pre_commit.util import mkdirp
|
||||||
|
|
@ -234,10 +235,16 @@ def test_install_idempotent(tempdir_factory, store):
|
||||||
|
|
||||||
def _path_without_us():
|
def _path_without_us():
|
||||||
# Choose a path which *probably* doesn't include us
|
# Choose a path which *probably* doesn't include us
|
||||||
return os.pathsep.join([
|
env = dict(os.environ)
|
||||||
x for x in os.environ['PATH'].split(os.pathsep)
|
exe = find_executable('pre-commit', _environ=env)
|
||||||
if x.lower() != os.path.dirname(sys.executable).lower()
|
while exe:
|
||||||
])
|
parts = env['PATH'].split(os.pathsep)
|
||||||
|
after = [x for x in parts if x.lower() != os.path.dirname(exe).lower()]
|
||||||
|
if parts == after:
|
||||||
|
raise AssertionError(exe, parts)
|
||||||
|
env['PATH'] = os.pathsep.join(after)
|
||||||
|
exe = find_executable('pre-commit', _environ=env)
|
||||||
|
return env['PATH']
|
||||||
|
|
||||||
|
|
||||||
def test_environment_not_sourced(tempdir_factory, store):
|
def test_environment_not_sourced(tempdir_factory, store):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue