示例#1
0
 def __init__(self, temp_dir_for_excludes=None):
     Settings.__init__(self, None)
     self.add_section('Plugins')
     self.set('pythonpath', [])
     self.set('auto imports', [])
     if temp_dir_for_excludes:
         self.excludes = Excludes(temp_dir_for_excludes)
示例#2
0
文件: mocks.py 项目: leeloveying/RIDE
 def __init__(self, temp_dir_for_excludes=None):
     Settings.__init__(self, None)
     self.add_section("Plugins")
     self.set("pythonpath", [])
     self.set("auto imports", [])
     if temp_dir_for_excludes:
         self.excludes = Excludes(temp_dir_for_excludes)
示例#3
0
 def __init__(self, temp_dir_for_excludes=None):
     Settings.__init__(self, None)
     self.add_section('Plugins')
     self.set('pythonpath', [])
     self.set('auto imports', [])
     if temp_dir_for_excludes:
         self.excludes = Excludes(temp_dir_for_excludes)
示例#4
0
 def __init__(self, settings=None):
     Settings.__init__(self, None)
     self.add_section('Plugins')
     self.set('pythonpath', [])
     self.set('auto imports', [])
     if settings:
         for key, val in settings.items():
             self.set(key, val)
示例#5
0
 def __init__(self, settings=None):
     Settings.__init__(self, None)
     self.add_section('Plugins')
     self.set('pythonpath', [])
     self.set('auto imports', [])
     if settings:
         for key, val in settings.items():
             self.set(key, val)
示例#6
0
文件: mocks.py 项目: tbener/RIDE
 def __init__(self, temp_dir_for_excludes=None):
     Settings.__init__(self, None)
     self.add_section('Plugins')
     self.set('pythonpath', [])
     self.set('auto imports', [])
     self.set('use installed robot libraries', False)
     if temp_dir_for_excludes:
         self.excludes = Excludes(temp_dir_for_excludes)
示例#7
0
 def __init__(self, settings=None):
     Settings.__init__(self, None)
     self.add_section('Plugins')
     self.set('pythonpath', [])
     self.set('auto imports', [])
     self.set('use installed robot libraries', False)
     if settings:
         for key, val in settings.items():
             self.set(key, val)
示例#8
0
    def __init__(self, settings=None):
        fake_cfg = os.path.join(os.path.dirname(__file__), 'fake.cfg')

        # make sure fake cfg is clean
        with open(fake_cfg, 'wb') as f:
            f.write(_FAKE_CFG_CONTENT)

        Settings.__init__(self, fake_cfg)
        self.add_section('Plugins')
        self.set('pythonpath', [])
        self.set('auto imports', [])
        if settings:
            for key, val in settings.items():
                self.set(key, val)
示例#9
0
 def _read_settings(self, path=None):
     try:
         return Settings(self._get_path(path))
     except:
         # print("DEBUG: settings utils_READ SETTINGS_errored path %s" % path)
         print(self._read_settings_file_content())
         raise
示例#10
0
 def test_settings_file_content_stay(self):
     self._write_settings(SETTINGS_CONTENT)
     settings = Settings(self.user_settings_path)
     settings['string'] = 'new value'
     settings['Section 1']['robot'] = 'New Robot'
     expected = SETTINGS_CONTENT.replace('REPLACE_STRING', 'new value')
     expected = expected.replace('REPLACE_ROBOT', 'New Robot')
     self.assertEquals(self._read_settings_file_content(), expected)
示例#11
0
class TestSettings(TestSettingsHelper):
    def test_changing_settings_with_setitem(self):
        self._create_settings_with_defaults()
        self.settings['foo'] = 'new value'
        self._check_content({'foo': 'new value', 'hello': 'world'})

    def test_getting_settings_with_getitem(self):
        self._create_settings_with_defaults()
        self.assertEquals('bar', self.settings['foo'])

    def _create_settings_with_defaults(self):
        self._write_settings("foo = 'bar'\nhello = 'world'",
                             self.user_settings_path)
        self.default = {'foo': 'bar', 'hello': 'world'}
        self.settings = Settings(self.user_settings_path)

    def test_set(self):
        self._create_settings_with_defaults()
        self.settings.set('foo', 'new value')
        self._check_content({'foo': 'new value', 'hello': 'world'})

    def test_set_with_non_existing_value(self):
        self._create_settings_with_defaults()
        self.settings.set('zip', 2)
        self._check_content({'foo': 'bar', 'hello': 'world', 'zip': 2})

    def test_set_without_autosave(self):
        self._create_settings_with_defaults()
        self.settings.set('foo', 'new value', autosave=False)
        self._check_content(self.default, check_self_settings=False)
        expected = {'foo': 'new value', 'hello': 'world'}
        self.assertEquals(self.settings._config_obj, expected)
        self.settings.save()
        self._check_content(expected)

    def test_set_without_override_when_settings_does_not_exist(self):
        self.settings.set('foo', 'new value', override=False)
        self._check_content({'foo': 'new value'})

    def test_set_without_override_when_settings_exists(self):
        self._create_settings_with_defaults()
        self.settings.set('foo', 'new value', override=False)
        self._check_content(self.default)

    def test_set_values(self):
        self._create_settings_with_defaults()
        self.settings.set_values({'foo': 'new value', 'int': 1})
        self._check_content({'foo': 'new value', 'hello': 'world', 'int': 1})

    def test_set_values_without_autosave(self):
        self._create_settings_with_defaults()
        self.settings.set_values({
            'foo': 'new value',
            'int': 1
        },
                                 autosave=False)
        expected = {'foo': 'new value', 'hello': 'world', 'int': 1}
        self.assertEquals(self.settings._config_obj, expected)
        self._check_content(self.default, check_self_settings=False)
        self.settings.save()
        self._check_content(expected)

    def test_set_values_without_override(self):
        self._create_settings_with_defaults()
        self.settings.set_values({
            'foo': 'not set',
            'new item': 'is set'
        },
                                 override=False)
        self.default['new item'] = 'is set'
        self._check_content(self.default)

    def test_set_values_with_none(self):
        self._create_settings_with_defaults()
        self.settings.set_values(None)
        self._check_content(self.default)

    def test_set_defaults(self):
        self.settings.set_defaults(foo='bar', zip=3)
        self._check_content({'foo': 'bar', 'zip': 3})

    def test_set_defaults_when_some_values_already_exists(self):
        self._create_settings_with_defaults()
        self.settings.set_defaults(foo='value', zip=3)
        self._check_content({'foo': 'bar', 'hello': 'world', 'zip': 3})
示例#12
0
 def test_setting_name_with_space(self):
     self.settings['name with space'] = 0
     settings = Settings(self.user_settings_path)
     self.assertEquals(settings['name with space'], 0)
 def _create_app(self):
     app = FakeApplication()
     settings = Settings(self._settings_path)
     settings.add_section('Plugins')
     app.settings = settings
     return app
示例#14
0
 def __init__(self):
     Settings.__init__(self, None)
     self.add_section('Plugins')
     self.set('pythonpath', [])
     self.set('auto imports', [])
示例#15
0
 def _create_settings_with_defaults(self):
     self._write_settings(
         "foo = 'bar'\nhello = 'world'", self.user_settings_path)
     self.default = {'foo': 'bar', 'hello': 'world'}
     self.settings = Settings(self.user_settings_path)
示例#16
0
 def _check_content(self, expected_dict, check_self_settings=True):
     settings = Settings(self.user_settings_path)
     self.assertEqual(settings._config_obj, expected_dict)
     if check_self_settings:
         self.assertEqual(self.settings._config_obj, expected_dict)
示例#17
0
 def _create_app(self):
     app = FakeApplication()
     settings = Settings(self._settings_path)
     settings.add_section('Plugins')
     app.settings = settings
     return app
示例#18
0
class TestSettings(TestSettingsHelper):
    def test_changing_settings_with_setitem(self):
        self._create_settings_with_defaults()
        self.settings["foo"] = "new value"
        self._check_content({"foo": "new value", "hello": "world"})

    def test_getting_settings_with_getitem(self):
        self._create_settings_with_defaults()
        self.assertEquals("bar", self.settings["foo"])

    def _create_settings_with_defaults(self):
        self._write_settings("foo = 'bar'\nhello = 'world'", self.user_settings_path)
        self.default = {"foo": "bar", "hello": "world"}
        self.settings = Settings(self.user_settings_path)

    def test_set(self):
        self._create_settings_with_defaults()
        self.settings.set("foo", "new value")
        self._check_content({"foo": "new value", "hello": "world"})

    def test_set_with_non_existing_value(self):
        self._create_settings_with_defaults()
        self.settings.set("zip", 2)
        self._check_content({"foo": "bar", "hello": "world", "zip": 2})

    def test_set_without_autosave(self):
        self._create_settings_with_defaults()
        self.settings.set("foo", "new value", autosave=False)
        self._check_content(self.default, check_self_settings=False)
        expected = {"foo": "new value", "hello": "world"}
        self.assertEquals(self.settings._config_obj, expected)
        self.settings.save()
        self._check_content(expected)

    def test_set_without_override_when_settings_does_not_exist(self):
        self.settings.set("foo", "new value", override=False)
        self._check_content({"foo": "new value"})

    def test_set_without_override_when_settings_exists(self):
        self._create_settings_with_defaults()
        self.settings.set("foo", "new value", override=False)
        self._check_content(self.default)

    def test_set_values(self):
        self._create_settings_with_defaults()
        self.settings.set_values({"foo": "new value", "int": 1})
        self._check_content({"foo": "new value", "hello": "world", "int": 1})

    def test_set_values_without_autosave(self):
        self._create_settings_with_defaults()
        self.settings.set_values({"foo": "new value", "int": 1}, autosave=False)
        expected = {"foo": "new value", "hello": "world", "int": 1}
        self.assertEquals(self.settings._config_obj, expected)
        self._check_content(self.default, check_self_settings=False)
        self.settings.save()
        self._check_content(expected)

    def test_set_values_without_override(self):
        self._create_settings_with_defaults()
        self.settings.set_values({"foo": "not set", "new item": "is set"}, override=False)
        self.default["new item"] = "is set"
        self._check_content(self.default)

    def test_set_values_with_none(self):
        self._create_settings_with_defaults()
        self.settings.set_values(None)
        self._check_content(self.default)

    def test_set_defaults(self):
        self.settings.set_defaults(foo="bar", zip=3)
        self._check_content({"foo": "bar", "zip": 3})

    def test_set_defaults_when_some_values_already_exists(self):
        self._create_settings_with_defaults()
        self.settings.set_defaults(foo="value", zip=3)
        self._check_content({"foo": "bar", "hello": "world", "zip": 3})
示例#19
0
 def _create_settings_with_defaults(self):
     self._write_settings("foo = 'bar'\nhello = 'world'", self.user_settings_path)
     self.default = {"foo": "bar", "hello": "world"}
     self.settings = Settings(self.user_settings_path)
示例#20
0
 def _read_settings(self, path=None):
     try:
         return Settings(self._get_path(path))
     except:
         print self._read_settings_file_content()
         raise
示例#21
0
 def _create_settings_with_defaults(self):
     self._write_settings("foo = 'bar'\nhello = 'world'",
                          self.user_settings_path)
     self.default = {'foo': 'bar', 'hello': 'world'}
     self.settings = Settings(self.user_settings_path)
示例#22
0
class TestSettings(TestSettingsHelper):

    def test_changing_settings_with_setitem(self):
        self._create_settings_with_defaults()
        self.settings['foo'] = 'new value'
        self._check_content({'foo': 'new value', 'hello': 'world'})

    def test_getting_settings_with_getitem(self):
        self._create_settings_with_defaults()
        self.assertEquals('bar', self.settings['foo'])

    def _create_settings_with_defaults(self):
        self._write_settings(
            "foo = 'bar'\nhello = 'world'", self.user_settings_path)
        self.default = {'foo': 'bar', 'hello': 'world'}
        self.settings = Settings(self.user_settings_path)

    def test_set(self):
        self._create_settings_with_defaults()
        self.settings.set('foo', 'new value')
        self._check_content({'foo': 'new value', 'hello': 'world'})

    def test_set_with_non_existing_value(self):
        self._create_settings_with_defaults()
        self.settings.set('zip', 2)
        self._check_content({'foo': 'bar', 'hello': 'world', 'zip': 2})

    def test_set_without_autosave(self):
        self._create_settings_with_defaults()
        self.settings.set('foo', 'new value', autosave=False)
        self._check_content(self.default, check_self_settings=False)
        expected = {'foo': 'new value', 'hello': 'world'}
        self.assertEquals(self.settings._config_obj, expected)
        self.settings.save()
        self._check_content(expected)

    def test_set_without_override_when_settings_does_not_exist(self):
        self.settings.set('foo', 'new value', override=False)
        self._check_content({'foo': 'new value'})

    def test_set_without_override_when_settings_exists(self):
        self._create_settings_with_defaults()
        self.settings.set('foo', 'new value', override=False)
        self._check_content(self.default)

    def test_set_values(self):
        self._create_settings_with_defaults()
        self.settings.set_values({'foo': 'new value', 'int': 1})
        self._check_content({'foo': 'new value', 'hello': 'world', 'int': 1})

    def test_set_values_without_autosave(self):
        self._create_settings_with_defaults()
        self.settings.set_values(
            {'foo': 'new value', 'int': 1}, autosave=False)
        expected = {'foo': 'new value', 'hello': 'world', 'int': 1}
        self.assertEquals(self.settings._config_obj, expected)
        self._check_content(self.default, check_self_settings=False)
        self.settings.save()
        self._check_content(expected)

    def test_set_values_without_override(self):
        self._create_settings_with_defaults()
        self.settings.set_values({'foo': 'not set', 'new item': 'is set'},
                                 override=False)
        self.default['new item'] = 'is set'
        self._check_content(self.default)

    def test_set_values_with_none(self):
        self._create_settings_with_defaults()
        self.settings.set_values(None)
        self._check_content(self.default)

    def test_set_defaults(self):
        self.settings.set_defaults(foo='bar', zip=3)
        self._check_content({'foo': 'bar', 'zip': 3})

    def test_set_defaults_when_some_values_already_exists(self):
        self._create_settings_with_defaults()
        self.settings.set_defaults(foo='value', zip=3)
        self._check_content({'foo': 'bar', 'hello': 'world', 'zip': 3})
示例#23
0
 def test_invalid_settings(self):
     self._write_settings('invalid syntax = foo')
     with self.assertRaises(ConfigurationError):
         settings = Settings(self.user_settings_path)
示例#24
0
 def test_invalid_settings(self):
     self._write_settings('invalid syntax = foo')
     settings = Settings(self.user_settings_path)
     # DEBUG Error is not raised
     '''