Skip to content

Commit 5ca3ffa

Browse files
committed
try using unittest logging func instead
1 parent b5051df commit 5ca3ffa

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

tests/test_varys.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import logging
77
from varys import Varys
88
import pika
9-
import pytest
109

1110
DIR = os.path.dirname(__file__)
1211
LOG_FILENAME = os.path.join(DIR, "test.log")
@@ -232,10 +231,6 @@ def test_quick_turnaround(self):
232231

233232
class TestVarysPermissions(unittest.TestCase):
234233

235-
@pytest.fixture(autouse=True)
236-
def inject_fixtures(self, caplog):
237-
self._caplog = caplog
238-
239234
def setUp(self):
240235
config = {
241236
"version": "0.1",
@@ -308,12 +303,14 @@ def tearDown(self):
308303
self.assertEqual(len(logger.handlers), 0)
309304

310305
def test_not_permitted_declare_fail(self):
311-
self.v.send(TEXT, "test-exchange-2", queue_suffix="test_queue")
312-
print(self._caplog.text)
313-
self.assertTrue(
314-
"pika.exceptions.ChannelClosedByBroker: (403, \"ACCESS_REFUSED - configure access to exchange 'test-exchange-2' in vhost '/' refused for user 'guest2'\")"
315-
in self._caplog.text
316-
)
306+
with self.assertLogs("test-exchange-2", level="DEBUG") as cm:
307+
self.v.send(TEXT, "test-exchange-2", queue_suffix="test_queue")
308+
self.assertTrue(
309+
any(
310+
"pika.exceptions.ChannelClosedByBroker: (403, " in message
311+
for message in cm.output
312+
)
313+
)
317314

318315
def test_send_receive_extant_queue(self):
319316
self.v.send(TEXT, "test-exchange", queue_suffix="test_queue")

0 commit comments

Comments
 (0)