mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
37e94b1e1e
1 changed files with 18 additions and 6 deletions
|
|
@ -1,15 +1,27 @@
|
||||||
|
|
||||||
|
import contextlib
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from plumbum import local
|
from plumbum import local
|
||||||
from pre_commit import git
|
from pre_commit import git
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def in_dir(dir):
|
||||||
|
old_path = local.cwd.getpath()
|
||||||
|
local.cwd.chdir(dir)
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
local.cwd.chdir(old_path)
|
||||||
|
|
||||||
|
@pytest.yield_fixture
|
||||||
def empty_git_dir(tmpdir):
|
def empty_git_dir(tmpdir):
|
||||||
local.cwd.chdir(tmpdir.strpath)
|
with in_dir(tmpdir.strpath):
|
||||||
local['git']['init']()
|
local['git']['init']()
|
||||||
return tmpdir.strpath
|
yield tmpdir.strpath
|
||||||
|
|
||||||
|
|
||||||
def test_get_root(empty_git_dir):
|
def test_get_root(empty_git_dir):
|
||||||
|
|
@ -17,8 +29,8 @@ def test_get_root(empty_git_dir):
|
||||||
|
|
||||||
foo = local.path('foo')
|
foo = local.path('foo')
|
||||||
foo.mkdir()
|
foo.mkdir()
|
||||||
local.cwd.chdir(foo)
|
|
||||||
|
|
||||||
|
with in_dir(foo):
|
||||||
assert git.get_root() == empty_git_dir
|
assert git.get_root() == empty_git_dir
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue