Пример #1
0
    def save(self, filename=None):
        """
        Save the configuration.

        If no ``filename`` is given, the configuration is saved to the default
        configuration file as returned by
        :func:`get_management_config_file_path`.  Otherwise the configuration
        is saved to the given file.

        ``filename`` is either ``None`` or a string containing the path to a
        file.

        Raise :exc:`~exceptions.EnvironmentError`, if the file could not be
        written.
        """
        if not filename:
            filename = get_management_config_file_path()
        save_json(filename, dict(self))
Пример #2
0
    def save(self, filename=None):
        """
        Save the configuration.

        If no ``filename`` is given, the configuration is saved to the default
        configuration file as returned by
        :func:`get_management_config_file_path`.  Otherwise the configuration
        is saved to the given file.

        ``filename`` is either ``None`` or a string containing the path to a
        file.

        Raise :exc:`~exceptions.EnvironmentError`, if the file could not be
        written.
        """
        if not filename:
            filename = get_management_config_file_path()
        save_json(filename, dict(self))
Пример #3
0
def test_save_json_no_perms(tmpdir, json_file, json_obj):
    tmpdir.chmod(550)
    with pytest.raises(EnvironmentError) as excinfo:
        util.save_json(str(json_file), json_obj)
    assert excinfo.value.filename == str(json_file)
    assert excinfo.value.errno == errno.EACCES
Пример #4
0
def test_save_json(json_file, json_obj):
    assert not json_file.check(file=True, exists=True)
    util.save_json(str(json_file), json_obj)
    assert json_file.check(file=True)
    assert json.loads(json_file.read()) == json_obj