MCPcopy Index your code
hub / github.com/RustPython/RustPython / setUp

Method setUp

Lib/test/test_logging.py:2033–2057  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

2031 address = ('localhost', 0)
2032
2033 def setUp(self):
2034 """Set up a UDP server to receive log messages, and a SysLogHandler
2035 pointing to that server's address and port."""
2036 BaseTest.setUp(self)
2037 # Issue #29177: deal with errors that happen during setup
2038 self.server = self.sl_hdlr = self.server_exception = None
2039 try:
2040 self.server = server = self.server_class(self.address,
2041 self.handle_datagram, 0.01)
2042 server.start()
2043 # Uncomment next line to test error recovery in setUp()
2044 # raise OSError('dummy error raised')
2045 except OSError as e:
2046 self.server_exception = e
2047 return
2048 server.ready.wait()
2049 hcls = logging.handlers.SysLogHandler
2050 if isinstance(server.server_address, tuple):
2051 self.sl_hdlr = hcls((server.server_address[0], server.port))
2052 else:
2053 self.sl_hdlr = hcls(server.server_address)
2054 self.log_output = b''
2055 self.root_logger.removeHandler(self.root_logger.handlers[0])
2056 self.root_logger.addHandler(self.sl_hdlr)
2057 self.handled = threading.Event()
2058
2059 def tearDown(self):
2060 """Shutdown the server."""

Callers

nothing calls this directly

Calls 7

isinstanceFunction · 0.85
removeHandlerMethod · 0.80
addHandlerMethod · 0.80
EventMethod · 0.80
setUpMethod · 0.45
startMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected