-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
28 lines (19 loc) · 808 Bytes
/
conftest.py
File metadata and controls
28 lines (19 loc) · 808 Bytes
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
from pathlib import Path
import pytest
import pythonnet
def pytest_addoption(parser):
parser.addoption("--test-file", action="store", default=None)
parser.addoption("--test-verbose", action="store_true", default=False)
@pytest.fixture
def path_is_file_fails(monkeypatch):
"""Make Path.is_file return False so load_runtime will raise FileNotFoundError."""
monkeypatch.setattr(Path, "is_file", lambda self: False)
@pytest.fixture
def pythonnet_load_raises(monkeypatch):
"""Make pythonnet.load raise RuntimeError while keeping the DLL present."""
monkeypatch.setattr(Path, "is_file", lambda self: True)
def _raise(runtime) -> None:
_ = runtime
msg = "failed to init runtime"
raise RuntimeError(msg)
monkeypatch.setattr(pythonnet, "load", _raise)