blob: 4ed5ac3ea402ec778e716053afc8387756efc870 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
from contextlib import contextmanager
import os
from pathlib import Path
from tempfile import TemporaryDirectory
from flit import vcs
@contextmanager
def cwd(path):
if isinstance(path, Path):
path = str(path)
old_wd = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(old_wd)
def test_identify_git_parent():
with TemporaryDirectory() as td:
td = Path(td)
(td / '.git').mkdir()
subdir = (td / 'subdir')
subdir.mkdir()
with cwd(subdir):
assert vcs.identify_vcs(Path('.')).name == 'git'
|