Skip to content

Commit d8aebf9

Browse files
committed
Don't rely on monkeypatching for find caller test
1 parent 575e2a4 commit d8aebf9

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

tests/test_stdlib.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,17 @@ def test_no_stack_info_by_default(self):
137137

138138
assert None is stack_info
139139

140-
def test_find_caller(self, monkeypatch):
140+
def test_find_caller(self, caplog):
141141
"""
142142
The caller is found.
143143
"""
144144
logger = LoggerFactory()()
145-
log_handle = call_recorder(lambda x: None)
146-
monkeypatch.setattr(logger, "handle", log_handle)
147145

148146
logger.error("Test")
149147

150-
log_record = log_handle.calls[0].args[0]
151-
152-
assert log_record.funcName == "test_find_caller"
153-
assert log_record.name == __name__
154-
assert log_record.filename == os.path.basename(__file__)
148+
assert caplog.text.startswith(
149+
"ERROR tests.test_stdlib:test_stdlib.py"
150+
)
155151

156152
def test_sets_correct_logger(self):
157153
"""

0 commit comments

Comments
 (0)