/
conftest.py
35 lines (26 loc) · 994 Bytes
/
conftest.py
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
import os
import sys
import pytest
from pathlib import Path
from snakemake.common import ON_WINDOWS
from snakemake.utils import find_bash_on_windows
from snakemake import shell
skip_on_windows = pytest.mark.skipif(ON_WINDOWS, reason="Unix stuff")
only_on_windows = pytest.mark.skipif(not ON_WINDOWS, reason="Windows stuff")
needs_strace = pytest.mark.xfail(
os.system("strace -o /dev/null true") != 0, reason="Missing strace"
)
@pytest.fixture(autouse=True)
def reset_paths_between_tests():
"""Ensure that changes to sys.path are reset between tests"""
org_path = sys.path.copy()
yield
sys.path = org_path
bash_cmd = find_bash_on_windows()
if ON_WINDOWS and bash_cmd:
@pytest.fixture(autouse=True)
def prepend_usable_bash_to_path(monkeypatch):
monkeypatch.setenv("PATH", os.path.dirname(bash_cmd), prepend=os.pathsep)
@pytest.fixture(autouse=True)
def reset_shell_exec_on_windows(prepend_usable_bash_to_path):
shell.executable(None)