Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pytest and caplog
#1
Hi.

I have the folowing test class:

class TestConnection(AsyncTestCase):
      '''Integration test'''

      @gen_test
      def test_connecting_to_server(self):
          '''Connecting to the TCPserver'''
          client = server = None
          try:
              sock, port = bind_unused_port()
              with NullContext():
                  server = EchoServer()
                  server.add_socket(sock)
              client = IOStream(socket.socket())
              with ExpectLog(caplog, '.*decode.*'):
                  yield client.connect(('localhost', port))
                  yield client.write(b'hello\n')
                  # yield client.read_until(b'\n')
                  yield gen.moment
                  assert False
          finally:
              if server is not None:
                  server.stop()
              if client is not None:
                  client.close()
Can someone explain how to gain access to the caplog fixture inside the test method so that I can work with my logs ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pytest Installed, but VS Code Won’t Access Pytest AstralWeeks 9 2,892 Sep-13-2023, 03:00 PM
Last Post: AstralWeeks
  Pytest mocks anthonyrmoss78 0 427 May-30-2023, 08:28 PM
Last Post: anthonyrmoss78
  Pytest and rootdirectory Master_Sergius 4 4,564 Jun-01-2020, 05:05 PM
Last Post: Master_Sergius
  Pytest with requests a21250450 3 2,731 Mar-21-2019, 03:24 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020