forked from LiveCarta/ContentGeneration
Refactor src layout and add logging lifecycle + tests
This commit is contained in:
25
tests/test_logging_decorator.py
Normal file
25
tests/test_logging_decorator.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
from src.logging_config import debug_log_lifecycle
|
||||
|
||||
|
||||
class TestDebugLogLifecycle(unittest.TestCase):
|
||||
def test_logs_function_start_and_end(self) -> None:
|
||||
@debug_log_lifecycle
|
||||
def sample(a: int, b: int) -> int:
|
||||
return a + b
|
||||
|
||||
with self.assertLogs(sample.__module__, level="DEBUG") as captured:
|
||||
result = sample(2, 3)
|
||||
|
||||
self.assertEqual(result, 5)
|
||||
joined = "\n".join(captured.output)
|
||||
self.assertIn("Start TestDebugLogLifecycle.test_logs_function_start_and_end.<locals>.sample", joined)
|
||||
self.assertIn("End TestDebugLogLifecycle.test_logs_function_start_and_end.<locals>.sample", joined)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user