Skip to content

Commit 44530e7

Browse files
committed
use caplog properly
1 parent 6b10da6 commit 44530e7

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tests/test_varys.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
from varys import Varys
88
import pika
9-
from pika import exceptions as pika_exceptions
9+
import pytest
1010

1111
DIR = os.path.dirname(__file__)
1212
LOG_FILENAME = os.path.join(DIR, "test.log")
@@ -232,6 +232,10 @@ def test_quick_turnaround(self):
232232

233233
class TestVarysPermissions(unittest.TestCase):
234234

235+
@pytest.fixture(autouse=True)
236+
def inject_fixtures(self, caplog):
237+
self._caplog = caplog
238+
235239
def setUp(self):
236240
config = {
237241
"version": "0.1",
@@ -303,11 +307,11 @@ def tearDown(self):
303307
logger = logging.getLogger("test_varys")
304308
self.assertEqual(len(logger.handlers), 0)
305309

306-
def test_not_permitted_declare_fail(self, caplog):
310+
def test_not_permitted_declare_fail(self):
307311
self.v.send(TEXT, "test-exchange-2", queue_suffix="test_queue")
308312
self.assertTrue(
309313
"pika.exceptions.ChannelClosedByBroker: (403, \"ACCESS_REFUSED - configure access to exchange 'test-exchange-2' in vhost '/' refused for user 'guest2'\")"
310-
in caplog.text
314+
in self._caplog.text
311315
)
312316

313317
def test_send_receive_extant_queue(self):

0 commit comments

Comments
 (0)