We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ba3eb2e commit 1291505Copy full SHA for 1291505
tests/functional/test_logger.py
@@ -1,3 +1,4 @@
1
+import inspect
2
import io
3
import json
4
import logging
@@ -344,3 +345,17 @@ def test_logger_level_env_var_as_int(monkeypatch):
344
345
monkeypatch.setenv("LOG_LEVEL", 50)
346
with pytest.raises(ValueError, match="Unknown level: '50'"):
347
Logger()
348
+
349
350
+def test_logger_record_caller_location(stdout):
351
+ # GIVEN Logger is initialized
352
+ logger = Logger(stream=stdout)
353
354
+ # WHEN log statement is run
355
+ logger.info("log")
356
357
+ # THEN 'location' field should have
358
+ # the correct caller resolution
359
+ caller_fn_name = inspect.currentframe().f_code.co_name
360
+ log = capture_logging_output(stdout)
361
+ assert caller_fn_name in log["location"]
0 commit comments