MCPcopy Index your code
hub / github.com/python/cpython / setUp

Method setUp

Lib/test/test_logging.py:1861–1885  ·  view source on GitHub ↗

Set up a TCP server to receive log messages, and a SocketHandler pointing to that server's address and port.

(self)

Source from the content-addressed store, hash-verified

1859 address = ('localhost', 0)
1860
1861 def setUp(self):
1862 """Set up a TCP server to receive log messages, and a SocketHandler
1863 pointing to that server's address and port."""
1864 BaseTest.setUp(self)
1865 # Issue #29177: deal with errors that happen during setup
1866 self.server = self.sock_hdlr = self.server_exception = None
1867 try:
1868 self.server = server = self.server_class(self.address,
1869 self.handle_socket, 0.01)
1870 server.start()
1871 # Uncomment next line to test error recovery in setUp()
1872 # raise OSError('dummy error raised')
1873 except OSError as e:
1874 self.server_exception = e
1875 return
1876 server.ready.wait()
1877 hcls = logging.handlers.SocketHandler
1878 if isinstance(server.server_address, tuple):
1879 self.sock_hdlr = hcls('localhost', server.port)
1880 else:
1881 self.sock_hdlr = hcls(server.server_address, None)
1882 self.log_output = ''
1883 self.root_logger.removeHandler(self.root_logger.handlers[0])
1884 self.root_logger.addHandler(self.sock_hdlr)
1885 self.handled = threading.Semaphore(0)
1886
1887 def tearDown(self):
1888 """Shutdown the TCP server."""

Callers

nothing calls this directly

Calls 6

removeHandlerMethod · 0.80
addHandlerMethod · 0.80
SemaphoreMethod · 0.80
setUpMethod · 0.45
startMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected