Skip to content

Commit 65104db

Browse files
committed
Adapt test for caplog fixture as instance attribute
1 parent c779e19 commit 65104db

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/tests_asyncio/test_browser_contexts.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717

1818
class MixinTestCaseMultipleContexts:
19+
@pytest.fixture(autouse=True)
20+
def inject_fixtures(self, caplog):
21+
caplog.set_level(logging.DEBUG)
22+
self._caplog = caplog
23+
1924
@pytest.mark.asyncio
2025
async def test_contexts_max_settings(self):
2126
settings = {
@@ -247,8 +252,7 @@ async def test_contexts_dynamic(self):
247252
assert cookie["domain"] == "example.org"
248253

249254
@pytest.mark.asyncio
250-
async def test_close_inactive_context(self, caplog):
251-
caplog.set_level(logging.DEBUG)
255+
async def test_close_inactive_context(self):
252256
spider = Spider("foo")
253257
async with make_handler(
254258
{
@@ -272,7 +276,7 @@ async def test_close_inactive_context(self, caplog):
272276
"scrapy-playwright",
273277
logging.INFO,
274278
"[Context=default] Closing inactive browser context",
275-
) in caplog.record_tuples
279+
) in self._caplog.record_tuples
276280

277281

278282
class TestCaseMultipleContextsChromium(IsolatedAsyncioTestCase, MixinTestCaseMultipleContexts):

0 commit comments

Comments
 (0)