本文整理汇总了Python中app.util.unhandled_exception_handler.UnhandledExceptionHandler.reset_singleton方法的典型用法代码示例。如果您正苦于以下问题:Python UnhandledExceptionHandler.reset_singleton方法的具体用法?Python UnhandledExceptionHandler.reset_singleton怎么用?Python UnhandledExceptionHandler.reset_singleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.util.unhandled_exception_handler.UnhandledExceptionHandler
的用法示例。
在下文中一共展示了UnhandledExceptionHandler.reset_singleton方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from app.util.unhandled_exception_handler import UnhandledExceptionHandler [as 别名]
# 或者: from app.util.unhandled_exception_handler.UnhandledExceptionHandler import reset_singleton [as 别名]
def setUp(self):
super().setUp()
self._set_up_safe_guards()
# Reset singletons so that they get recreated for every test that uses them.
Configuration.reset_singleton()
UnhandledExceptionHandler.reset_singleton()
# Explicitly initialize UnhandledExceptionHandler singleton here (on the main thread) since it sets up signal
# handlers that must execute on the main thread.
UnhandledExceptionHandler.singleton()
MasterConfigLoader().configure_defaults(Configuration.singleton())
MasterConfigLoader().configure_postload(Configuration.singleton())
self.patch('app.util.conf.master_config_loader.MasterConfigLoader.load_from_config_file')
# Configure logging to go to stdout. This makes debugging easier by allowing us to see logs for failed tests.
log.configure_logging('DEBUG')
# Then stub out configure_logging so we don't end up logging to real files during testing.
self.patch('app.util.log.configure_logging')
# Set up TestHandler. This allows asserting on log messages in tests.
self.log_handler = logbook.TestHandler(bubble=True)
self.log_handler.push_application()
self._base_setup_called = True
示例2: initialize_unhandled_exception_handler
# 需要导入模块: from app.util.unhandled_exception_handler import UnhandledExceptionHandler [as 别名]
# 或者: from app.util.unhandled_exception_handler.UnhandledExceptionHandler import reset_singleton [as 别名]
def initialize_unhandled_exception_handler():
# Note: Unfortunately we can't use `self.assertRaises` here since this executes on a different thread.
# todo: After exceptions in test threads are being caught, simplify this test to use self.assertRaises.
UnhandledExceptionHandler.reset_singleton()
try:
UnhandledExceptionHandler.singleton()
except Exception:
nonlocal exception_raised
exception_raised = True
示例3: test_handles_platform_does_not_support_SIGINFO
# 需要导入模块: from app.util.unhandled_exception_handler import UnhandledExceptionHandler [as 别名]
# 或者: from app.util.unhandled_exception_handler.UnhandledExceptionHandler import reset_singleton [as 别名]
def test_handles_platform_does_not_support_SIGINFO(self):
UnhandledExceptionHandler.reset_singleton()
mock_signal = self.patch('app.util.unhandled_exception_handler.signal')
def register_signal_handler(sig, _):
if sig == process_utils.SIGINFO:
raise ValueError
mock_signal.signal.side_effect = register_signal_handler
UnhandledExceptionHandler.singleton()
示例4: setUp
# 需要导入模块: from app.util.unhandled_exception_handler import UnhandledExceptionHandler [as 别名]
# 或者: from app.util.unhandled_exception_handler.UnhandledExceptionHandler import reset_singleton [as 别名]
def setUp(self):
super().setUp()
self.addCleanup(patch.stopall)
self._patched_items = {}
self._blacklist_methods_not_allowed_in_unit_tests()
# Stub out a few library dependencies that launch subprocesses.
self.patch('app.util.autoversioning.get_version').return_value = '0.0.0'
self.patch('app.util.conf.base_config_loader.platform.node').return_value = self._fake_hostname
if self._do_network_mocks:
# requests.Session() also makes some subprocess calls on instantiation.
self.patch('app.util.network.requests.Session')
# Stub out Network.are_hosts_same() call with a simple string comparison.
self.patch('app.util.network.Network.are_hosts_same', new=lambda host_a, host_b: host_a == host_b)
# Reset singletons so that they get recreated for every test that uses them.
Configuration.reset_singleton()
UnhandledExceptionHandler.reset_singleton()
SlaveRegistry.reset_singleton()
# Explicitly initialize UnhandledExceptionHandler singleton here (on the main thread) since it sets up signal
# handlers that must execute on the main thread.
UnhandledExceptionHandler.singleton()
MasterConfigLoader().configure_defaults(Configuration.singleton())
MasterConfigLoader().configure_postload(Configuration.singleton())
self.patch('app.util.conf.master_config_loader.MasterConfigLoader.load_from_config_file')
# Reset counters
Slave._slave_id_counter = Counter()
Build._build_id_counter = Counter()
analytics._event_id_generator = Counter()
# Configure logging to go to stdout. This makes debugging easier by allowing us to see logs for failed tests.
log.configure_logging('DEBUG')
# Then stub out configure_logging so we don't end up logging to real files during testing.
self.patch('app.util.log.configure_logging')
# Set up TestHandler. This allows asserting on log messages in tests.
self.log_handler = logbook.TestHandler(bubble=True)
self.log_handler.push_application()
self._base_setup_called = True