-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
40 lines (29 loc) · 1.1 KB
/
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
36
37
38
39
40
import os
from pathlib import Path
from typing import Any
import pytest
from typer.testing import CliRunner
from deploy_tools.__main__ import app
runner = CliRunner()
def run_cli(*args):
result = runner.invoke(app, [str(x) for x in args])
if result.exception:
raise result.exception
assert result.exit_code == 0, result
# Prevent pytest from catching exceptions when debugging in vscode so that break on
# exception works correctly (see: https://github.com/pytest-dev/pytest/issues/7409)
if os.getenv("PYTEST_RAISE", "0") == "1":
@pytest.hookimpl(tryfirst=True)
def pytest_exception_interact(call: pytest.CallInfo[Any]):
if call.excinfo is not None:
raise call.excinfo.value
else:
raise RuntimeError(
f"{call} has no exception data, an unknown error has occurred"
)
@pytest.hookimpl(tryfirst=True)
def pytest_internalerror(excinfo: pytest.ExceptionInfo[Any]):
raise excinfo.value
@pytest.fixture
def schemas():
return Path(__file__).parent.parent / "src" / "deploy_tools" / "models" / "schemas"