-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconftest.py
More file actions
41 lines (32 loc) · 1.1 KB
/
conftest.py
File metadata and controls
41 lines (32 loc) · 1.1 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import subprocess
from pathlib import Path
import pytest
GIT2CPP_TEST_WASM = os.getenv('GIT2CPP_TEST_WASM') == "1"
if GIT2CPP_TEST_WASM:
from .conftest_wasm import *
# Fixture to run test in current tmp_path
@pytest.fixture
def run_in_tmp_path(tmp_path):
original_cwd = os.getcwd()
os.chdir(tmp_path)
yield
os.chdir(original_cwd)
@pytest.fixture(scope="session")
def git2cpp_path():
if GIT2CPP_TEST_WASM:
return 'git2cpp'
else:
return Path(__file__).parent.parent / 'build' / 'git2cpp'
@pytest.fixture
def xtl_clone(git2cpp_path, tmp_path, run_in_tmp_path):
url = "https://github.com/xtensor-stack/xtl.git"
clone_cmd = [git2cpp_path, "clone", url]
p = subprocess.run(clone_cmd, capture_output=True, cwd=tmp_path, text=True)
assert p.returncode == 0
@pytest.fixture
def commit_env_config(monkeypatch):
monkeypatch.setenv("GIT_AUTHOR_NAME", "Jane Doe")
monkeypatch.setenv("GIT_AUTHOR_EMAIL", "jane.doe@blabla.com")
monkeypatch.setenv("GIT_COMMITTER_NAME", "Jane Doe")
monkeypatch.setenv("GIT_COMMITTER_EMAIL", "jane.doe@blabla.com")