-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
39 lines (29 loc) · 992 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
36
37
38
39
import os
import logging
from pathlib import Path
import typing as ty
import tempfile
import pytest
# Set DEBUG logging for unittests
log_level = logging.WARNING
logger = logging.getLogger("fileformats")
logger.setLevel(log_level)
sch = logging.StreamHandler()
sch.setLevel(log_level)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
sch.setFormatter(formatter)
logger.addHandler(sch)
# For debugging in IDE's don't catch raised exceptions and let the IDE
# break at it
if os.getenv("_PYTEST_RAISE", "0") != "0":
@pytest.hookimpl(tryfirst=True)
def pytest_exception_interact(call: pytest.CallInfo[ty.Any]) -> None:
if call.excinfo is not None:
raise call.excinfo.value
@pytest.hookimpl(tryfirst=True)
def pytest_internalerror(excinfo: pytest.ExceptionInfo[BaseException]) -> None:
raise excinfo.value
@pytest.fixture
def work_dir() -> Path:
work_dir = tempfile.mkdtemp()
return Path(work_dir)