@@ -38,54 +38,54 @@ def test_returns_true_during_test_run(self):
3838class TestConfigureLogging :
3939 """Test suite for configure_logging function."""
4040
41- def test_configure_logging_returns_bound_logger (self ):
41+ def test_configure_logging_returns_bound_logger (self , mock_settings ):
4242 """configure_logging returns a BoundLogger instance."""
43- result = configure_logging ()
43+ result = configure_logging (settings = mock_settings )
4444
4545 assert result is not None
4646 assert hasattr (result , "info" )
4747 assert hasattr (result , "debug" )
4848 assert hasattr (result , "warning" )
4949 assert hasattr (result , "error" )
5050
51- def test_configure_logging_default_parameters (self ):
51+ def test_configure_logging_default_parameters (self , mock_settings ):
5252 """configure_logging works with default parameters."""
53- logger = configure_logging ()
53+ logger = configure_logging (settings = mock_settings )
5454
5555 assert logger is not None
5656
57- def test_configure_logging_with_log_level (self ):
57+ def test_configure_logging_with_log_level (self , mock_settings ):
5858 """configure_logging accepts log_level parameter."""
5959 # In test environment, logging is suppressed, but function should still work
60- logger = configure_logging (log_level = "DEBUG" )
60+ logger = configure_logging (settings = mock_settings , log_level = "DEBUG" )
6161 assert logger is not None
6262
63- logger = configure_logging (log_level = "INFO" )
63+ logger = configure_logging (settings = mock_settings , log_level = "INFO" )
6464 assert logger is not None
6565
66- logger = configure_logging (log_level = "WARNING" )
66+ logger = configure_logging (settings = mock_settings , log_level = "WARNING" )
6767 assert logger is not None
6868
69- def test_configure_logging_with_is_production (self ):
69+ def test_configure_logging_with_is_production (self , mock_settings ):
7070 """configure_logging accepts is_production parameter."""
7171 # In test environment, logging is suppressed, but parameters should be accepted
72- logger = configure_logging (is_production = True )
72+ logger = configure_logging (settings = mock_settings , is_production = True )
7373 assert logger is not None
7474
75- logger = configure_logging (is_production = False )
75+ logger = configure_logging (settings = mock_settings , is_production = False )
7676 assert logger is not None
7777
78- def test_configure_logging_idempotent (self ):
78+ def test_configure_logging_idempotent (self , mock_settings ):
7979 """Multiple configure_logging calls are safe."""
80- logger1 = configure_logging ()
81- logger2 = configure_logging ()
80+ logger1 = configure_logging (settings = mock_settings )
81+ logger2 = configure_logging (settings = mock_settings )
8282
8383 assert logger1 is not None
8484 assert logger2 is not None
8585
86- def test_configure_logging_suppresses_in_test_env (self ):
86+ def test_configure_logging_suppresses_in_test_env (self , mock_settings ):
8787 """In test environment, root logger level is set high to suppress output."""
88- configure_logging ()
88+ configure_logging (settings = mock_settings )
8989
9090 # In test environment, root logger should be set to suppress output
9191 root_logger = logging .getLogger ()
@@ -97,9 +97,9 @@ def test_configure_logging_suppresses_in_test_env(self):
9797class TestGetModuleLogger :
9898 """Test suite for get_module_logger function (deprecated)."""
9999
100- def test_get_module_logger_returns_bound_logger (self ):
100+ def test_get_module_logger_returns_bound_logger (self , mock_settings ):
101101 """get_module_logger returns a BoundLogger with expected methods."""
102- configure_logging ()
102+ configure_logging (settings = mock_settings )
103103
104104 with warnings .catch_warnings (record = True ) as w :
105105 warnings .simplefilter ("always" )
@@ -114,16 +114,16 @@ def test_get_module_logger_returns_bound_logger(self):
114114 assert hasattr (logger , "info" )
115115 assert hasattr (logger , "bind" )
116116
117- def test_get_module_logger_emits_deprecation_warning (self ):
117+ def test_get_module_logger_emits_deprecation_warning (self , mock_settings ):
118118 """get_module_logger emits DeprecationWarning."""
119- configure_logging ()
119+ configure_logging (settings = mock_settings )
120120
121121 with pytest .warns (DeprecationWarning , match = "deprecated" ):
122122 get_module_logger ()
123123
124- def test_get_module_logger_still_works (self ):
124+ def test_get_module_logger_still_works (self , mock_settings ):
125125 """get_module_logger still returns functional logger for backward compat."""
126- configure_logging ()
126+ configure_logging (settings = mock_settings )
127127
128128 with warnings .catch_warnings ():
129129 warnings .simplefilter ("ignore" , DeprecationWarning )
@@ -140,9 +140,9 @@ def test_get_module_logger_still_works(self):
140140class TestLoggingBestPractices :
141141 """Tests demonstrating structlog best practices."""
142142
143- def test_standard_structlog_pattern (self ):
143+ def test_standard_structlog_pattern (self , mock_settings ):
144144 """Standard structlog.get_logger() pattern works."""
145- configure_logging ()
145+ configure_logging (settings = mock_settings )
146146
147147 # This is the recommended pattern
148148 logger = structlog .get_logger ()
@@ -151,29 +151,29 @@ def test_standard_structlog_pattern(self):
151151 assert hasattr (logger , "info" )
152152 assert hasattr (logger , "bind" )
153153
154- def test_bind_for_context (self ):
154+ def test_bind_for_context (self , mock_settings ):
155155 """Use .bind() for adding context."""
156- configure_logging ()
156+ configure_logging (settings = mock_settings )
157157
158158 logger = structlog .get_logger ()
159159 log = logger .bind (user_id = "123" , operation = "test" )
160160
161161 assert log is not None
162162 assert hasattr (log , "info" )
163163
164- def test_chained_binds (self ):
164+ def test_chained_binds (self , mock_settings ):
165165 """Multiple .bind() calls can be chained."""
166- configure_logging ()
166+ configure_logging (settings = mock_settings )
167167
168168 logger = structlog .get_logger ()
169169 log = logger .bind (request_id = "req-123" )
170170 log = log .bind (user_id = "user-456" )
171171
172172 assert log is not None
173173
174- def test_logging_methods_dont_raise (self ):
174+ def test_logging_methods_dont_raise (self , mock_settings ):
175175 """Logging methods execute without raising exceptions."""
176- configure_logging ()
176+ configure_logging (settings = mock_settings )
177177
178178 logger = structlog .get_logger ()
179179 log = logger .bind (component = "test" )
@@ -184,9 +184,9 @@ def test_logging_methods_dont_raise(self):
184184 log .warning ("warning message" )
185185 log .error ("error message" , error_code = "E001" )
186186
187- def test_exception_logging (self ):
187+ def test_exception_logging (self , mock_settings ):
188188 """Exception logging works correctly."""
189- configure_logging ()
189+ configure_logging (settings = mock_settings )
190190
191191 logger = structlog .get_logger ()
192192
0 commit comments