summaryrefslogtreecommitdiff
path: root/tests/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index fcf4189..58416ea 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,7 +1,30 @@
+import sys
+from typing import Callable
import pytest
+from logging import getLogger, DEBUG
+
from pyssg.arg_parser import get_parser
+from pyssg.custom_logger import setup_logger
@pytest.fixture(scope='session')
def arg_parser():
return get_parser()
+
+
+@pytest.fixture(scope='session')
+def logger():
+ setup_logger(__name__, DEBUG)
+ return getLogger(__name__)
+
+
+@pytest.fixture
+def capture_stdout(monkeypatch: Callable) -> dict[str, str | int]:
+ buffer: dict[str, str | int] = {'stdout': '', 'write_calls': 0}
+
+ def fake_writer(s):
+ buffer['stdout'] += s
+ buffer['write_calls'] += 1 # type: ignore
+
+ monkeypatch.setattr(sys.stdout, 'write', fake_writer)
+ return buffer