Coverage for tests / unit / utils / console / test_logger_initialization.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""Unit tests for ThreadSafeConsoleLogger initialization. 

2 

3Tests verify that the logger correctly initializes with and without 

4a run directory configuration. 

5""" 

6 

7from __future__ import annotations 

8 

9from pathlib import Path 

10 

11from assertpy import assert_that 

12 

13from lintro.utils.console.logger import ThreadSafeConsoleLogger 

14 

15 

16def test_init_with_run_dir(tmp_path: Path) -> None: 

17 """Verify ThreadSafeConsoleLogger correctly stores run directory when provided. 

18 

19 The run_dir parameter enables output logging to a specific directory. 

20 When provided, it should be accessible via the run_dir attribute. 

21 

22 Args: 

23 tmp_path: Temporary directory path for test files. 

24 """ 

25 logger = ThreadSafeConsoleLogger(run_dir=tmp_path) 

26 assert_that(logger.run_dir).is_equal_to(tmp_path) 

27 

28 

29def test_init_without_run_dir() -> None: 

30 """Verify ThreadSafeConsoleLogger initializes with None when no run directory provided. 

31 

32 When no run_dir is given, the attribute should be None, which disables 

33 file-based console logging features. 

34 """ 

35 logger = ThreadSafeConsoleLogger() 

36 assert_that(logger.run_dir).is_none()