コード例 #1
0
ファイル: test_loader.py プロジェクト: yjkominy/traitsui
    def test_load_import_error(self):
        # entry points are contributed by other packages, and loading them
        # may fail. In this test, the path is wrong and results in ImportError.
        error_entry_point = {
            "traitsui": {
                "etsdemo_data": [
                    "missing_demo={}:nonexisting_function".format(__name__),
                    "amazing_demo={}:amazing_demo_response".format(__name__),
                ],
            },
        }
        with mock_iter_entry_points(error_entry_point):
            with self.assertLogs(LOGGER_NAME) as watcher:
                resources = get_responses()

        self.assertEqual(len(resources), 1)
        log_output, = watcher.output
        self.assertIn("Failed to load entry point", log_output)
コード例 #2
0
ファイル: test_loader.py プロジェクト: yjkominy/traitsui
    def test_load_errored_entry_points(self):
        # entry points are contributed by other packages, and running them
        # may fail.
        error_entry_point = {
            "traitsui": {
                "etsdemo_data": [
                    "error_demo={}:misbehaving_demo_response".format(__name__),
                    "amazing_demo={}:amazing_demo_response".format(__name__),
                ],
            },
        }
        with mock_iter_entry_points(error_entry_point):
            with self.assertLogs(LOGGER_NAME) as watcher:
                resources = get_responses()

        self.assertEqual(len(resources), 1)
        log_output, = watcher.output
        self.assertIn("Failed to obtain data from", log_output)