Skip to content

Commit 24e31eb

Browse files
committed
test: fix test by injecting test logger into client.
Upgrading all the pytest modules to the latest changed how caplog worked in my test. Before caplog's root logger was initializing early enough to be inherited when the client module was loaded. However after the upgrade, I got the default root logger and caplog's output was empty. Inject the test cases logging.getLogger('roundup') to client.logger to get caplog working again.
1 parent dbeebd5 commit 24e31eb

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

test/rest_common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,6 +2308,10 @@ def testBadFormAttributeErrorException(self):
23082308
"REQUEST_METHOD": "GET"
23092309
}
23102310

2311+
# inject the caplog 'roundup' logger into client.
2312+
# otherwise this test fails.
2313+
# client logger instance was initialized without caplog
2314+
client.logger = logging.getLogger('roundup')
23112315

23122316
with self._caplog.at_level(logging.ERROR, logger="roundup"):
23132317
with self.assertRaises(AttributeError) as exc:

0 commit comments

Comments
 (0)