mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Move empty_git_dir out of pytest fixtures.
This commit is contained in:
parent
7b1230df27
commit
047a933554
10 changed files with 159 additions and 99 deletions
|
|
@ -1,9 +1,13 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import pytest
|
||||
from plumbum import local
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit.runner import Runner
|
||||
from testing.fixtures import git_dir
|
||||
|
||||
|
||||
def test_init_has_no_side_effects(tmpdir):
|
||||
|
|
@ -13,24 +17,26 @@ def test_init_has_no_side_effects(tmpdir):
|
|||
assert os.getcwd() == current_wd
|
||||
|
||||
|
||||
def test_create_sets_correct_directory(empty_git_dir):
|
||||
runner = Runner.create()
|
||||
assert runner.git_root == empty_git_dir
|
||||
assert os.getcwd() == empty_git_dir
|
||||
def test_create_sets_correct_directory(tmpdir_factory):
|
||||
path = git_dir(tmpdir_factory)
|
||||
with local.cwd(path):
|
||||
runner = Runner.create()
|
||||
assert runner.git_root == path
|
||||
assert os.getcwd() == path
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def git_dir_with_directory(empty_git_dir):
|
||||
os.mkdir('foo')
|
||||
yield empty_git_dir
|
||||
def test_create_changes_to_git_root(tmpdir_factory):
|
||||
path = git_dir(tmpdir_factory)
|
||||
with local.cwd(path):
|
||||
# Change into some directory, create should set to root
|
||||
foo_path = os.path.join(path, 'foo')
|
||||
os.mkdir(foo_path)
|
||||
os.chdir(foo_path)
|
||||
assert os.getcwd() != path
|
||||
|
||||
|
||||
def test_changes_to_root_of_git_dir(git_dir_with_directory):
|
||||
os.chdir('foo')
|
||||
assert os.getcwd() != git_dir_with_directory
|
||||
runner = Runner.create()
|
||||
assert runner.git_root == git_dir_with_directory
|
||||
assert os.getcwd() == git_dir_with_directory
|
||||
runner = Runner.create()
|
||||
assert runner.git_root == path
|
||||
assert os.getcwd() == path
|
||||
|
||||
|
||||
def test_config_file_path():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue