File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11
2+ import contextlib
23import os
34import pytest
45
56from plumbum import local
67from pre_commit import git
78
8- @pytest .fixture
9+
10+
11+ @contextlib .contextmanager
12+ def in_dir (dir ):
13+ old_path = local .cwd .getpath ()
14+ local .cwd .chdir (dir )
15+ try :
16+ yield
17+ finally :
18+ local .cwd .chdir (old_path )
19+
20+ @pytest .yield_fixture
921def empty_git_dir (tmpdir ):
10- local . cwd . chdir (tmpdir .strpath )
11- local ['git' ]['init' ]()
12- return tmpdir .strpath
22+ with in_dir (tmpdir .strpath ):
23+ local ['git' ]['init' ]()
24+ yield tmpdir .strpath
1325
1426
1527def test_get_root (empty_git_dir ):
1628 assert git .get_root () == empty_git_dir
1729
1830 foo = local .path ('foo' )
1931 foo .mkdir ()
20- local .cwd .chdir (foo )
2132
22- assert git .get_root () == empty_git_dir
33+ with in_dir (foo ):
34+ assert git .get_root () == empty_git_dir
2335
2436
2537def test_get_pre_commit_path (empty_git_dir ):
You can’t perform that action at this time.
0 commit comments