summaryrefslogtreecommitdiff
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2023-02-19 22:59:32 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2023-02-19 22:59:32 -0600
commite28fbb181851ca16bc0ade9c371628f86c25adbc (patch)
tree35db0440058600b36655956c61e080a08cb9d7ee /tests/conftest.py
parentb2fbb532e359985142a71354b5b648ae560a80ac (diff)
refactor custom logger and add tests
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