File: test_vcs.py

package info (click to toggle)
flit 3.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,504 kB
  • sloc: python: 6,691; makefile: 175; sh: 27
file content (26 lines) | stat: -rw-r--r-- 593 bytes parent folder | download | duplicates (2)
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
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'