当前位置: 首页>>代码示例>>Python>>正文


Python SettingsHandler._get_settings_filename方法代码示例

本文整理汇总了Python中Orange.widgets.settings.SettingsHandler._get_settings_filename方法的典型用法代码示例。如果您正苦于以下问题:Python SettingsHandler._get_settings_filename方法的具体用法?Python SettingsHandler._get_settings_filename怎么用?Python SettingsHandler._get_settings_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Orange.widgets.settings.SettingsHandler的用法示例。


在下文中一共展示了SettingsHandler._get_settings_filename方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_write_defaults_handles_permission_error

# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import _get_settings_filename [as 别名]
    def test_write_defaults_handles_permission_error(self):
        handler = SettingsHandler()

        with named_file("") as f:
            handler._get_settings_filename = lambda: f

            with patch('Orange.widgets.settings.open', create=True) as mocked_open:
                mocked_open.side_effect = PermissionError()

                handler.write_defaults()
开发者ID:benzei,项目名称:orange3,代码行数:12,代码来源:test_settings_handler.py

示例2: test_write_defaults_handles_permission_error

# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import _get_settings_filename [as 别名]
    def test_write_defaults_handles_permission_error(self):
        handler = SettingsHandler()

        with named_file("") as f:
            handler._get_settings_filename = lambda: f

            with patch("Orange.widgets.settings.log.error") as log, \
                patch('Orange.widgets.settings.open', create=True,
                       side_effect=PermissionError):
                handler.write_defaults()
                log.assert_called()
开发者ID:acopar,项目名称:orange3,代码行数:13,代码来源:test_settings_handler.py

示例3: test_read_defaults

# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import _get_settings_filename [as 别名]
    def test_read_defaults(self):
        default_settings = {'a': 5, 'b': {1: 5}}
        f, settings_file = mkstemp(suffix='.ini')
        with open(settings_file, 'wb') as f:
            pickle.dump(default_settings, f)

        handler = SettingsHandler()
        handler._get_settings_filename = lambda: settings_file
        handler.read_defaults()

        self.assertEqual(handler.defaults, default_settings)

        os.remove(settings_file)
开发者ID:Micseb,项目名称:orange3,代码行数:15,代码来源:test_settings_handler.py

示例4: override_default_settings

# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import _get_settings_filename [as 别名]
    def override_default_settings(self, widget, defaults=None):
        if defaults is None:
            defaults = {}

        h = SettingsHandler()
        h.widget_class = widget
        h.defaults = defaults
        filename = h._get_settings_filename()
        h.write_defaults()

        yield

        if os.path.isfile(filename):
            os.remove(filename)
开发者ID:benzei,项目名称:orange3,代码行数:16,代码来源:test_settings_handler.py

示例5: test_write_defaults

# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import _get_settings_filename [as 别名]
    def test_write_defaults(self):
        f, settings_file = mkstemp(suffix='.ini')

        handler = SettingsHandler()
        handler.defaults = {'a': 5, 'b': {1: 5}}
        handler._get_settings_filename = lambda: settings_file
        handler.write_defaults()

        with open(settings_file, 'rb') as f:
            default_settings = pickle.load(f)

        self.assertEqual(handler.defaults, default_settings)

        os.remove(settings_file)
开发者ID:Micseb,项目名称:orange3,代码行数:16,代码来源:test_settings_handler.py

示例6: override_default_settings

# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import _get_settings_filename [as 别名]
    def override_default_settings(self, widget, defaults=None):
        if defaults is None:
            defaults = {}

        h = SettingsHandler()
        h.widget_class = widget
        filename = h._get_settings_filename()
        with open(filename, "wb") as f:
            pickle.dump(defaults, f)

        yield

        if os.path.isfile(filename):
            os.remove(filename)
开发者ID:RachitKansal,项目名称:orange3,代码行数:16,代码来源:test_settings_handler.py

示例7: test_write_defaults_handles_writing_errors

# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import _get_settings_filename [as 别名]
    def test_write_defaults_handles_writing_errors(self):
        handler = SettingsHandler()

        for error in (EOFError, IOError, pickle.PicklingError):
            f = NamedTemporaryFile("wt", delete=False)
            f.close()  # so it can be opened on windows
            handler._get_settings_filename = lambda x=f: x.name

            with patch.object(handler, "write_defaults_file") as mocked_write:
                mocked_write.side_effect = error()

                handler.write_defaults()

            # Corrupt setting files should be removed
            self.assertFalse(os.path.exists(f.name))
开发者ID:benzei,项目名称:orange3,代码行数:17,代码来源:test_settings_handler.py

示例8: test_write_defaults

# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import _get_settings_filename [as 别名]
    def test_write_defaults(self):
        fd, settings_file = mkstemp(suffix='.ini')

        handler = SettingsHandler()
        handler.widget_class = SimpleWidget
        handler.defaults = {'a': 5, 'b': {1: 5}}
        handler._get_settings_filename = lambda: settings_file
        handler.write_defaults()

        with open(settings_file, 'rb') as f:
            default_settings = pickle.load(f)
        os.close(fd)

        self.assertEqual(default_settings.pop(VERSION_KEY, -0xBAD),
                         handler.widget_class.settings_version,)
        self.assertEqual(default_settings, handler.defaults)

        os.remove(settings_file)
开发者ID:acopar,项目名称:orange3,代码行数:20,代码来源:test_settings_handler.py


注:本文中的Orange.widgets.settings.SettingsHandler._get_settings_filename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。