diff --git a/README.rst b/README.rst
index 9df1ef9..2776c15 100644
--- a/README.rst
+++ b/README.rst
@@ -200,6 +200,29 @@ save it to a file like "cli.py" and then call it after installing click:
 whithout needing to set any env vars.
 
 
+Testing
+-------
+
+When testing your application, different behaviours often depend on settings
+taking on different values. Assuming that you are using a single `Settings`
+object accross multiple functions or modules, handling these settings changes
+in tests can be tricky.
+
+The settings object provides a simple method for modifying your settings object
+temporarily:
+
+.. code:: python
+
+   settings_map.update({'a': 1})
+   # Enter a temporary changes context block:
+   with settings_map.temporary_changes():
+       settings_map.update({'a': 1})
+       # Inside the context, the settings can be modified and used as you choose
+       print(settings_map['a'])  # outputs: 2
+   # After the context exits the settings map
+   print(settings_map['a'])  # outputs: 1
+
+
 .. |Build Status| image:: https://travis-ci.org/daviskirk/climatecontrol.svg?branch=master
    :target: https://travis-ci.org/daviskirk/climatecontrol
 .. |Coverage Status| image:: https://coveralls.io/repos/github/daviskirk/climatecontrol/badge.svg?branch=master
diff --git a/climatecontrol/settings_parser.py b/climatecontrol/settings_parser.py
index ab45c47..40b8bc8 100644
--- a/climatecontrol/settings_parser.py
+++ b/climatecontrol/settings_parser.py
@@ -1,6 +1,7 @@
 """Settings parser."""
 
 from abc import ABC, abstractmethod
+from contextlib import contextmanager
 import os
 import json
 import toml
@@ -312,6 +313,31 @@ class Settings(Mapping):
                 new_data[k] = parsed_v
         return new_data
 
+    @contextmanager
+    def temporary_changes(self):
+        """Open a context where any changes to the settings are rolled back on context exit.
+
+        This context manager can be used for testing or to temporarily change
+        settings.
+
+        Example:
+            >>> from climatecontrol.settings_parser import Settings
+            >>> settings = Settings()
+            >>> settings.update({'a': 1})
+            >>> with settings.temporary_changes():
+            ...     settings.update({'a': 2})
+            ...     assert settings['a'] == 2
+            >>> assert settings['a'] == 1
+
+        """
+        archived_settings = deepcopy(self._data)
+        archived_settings_files = deepcopy(self._settings_files)
+        archived_external_data = deepcopy(self.external_data)
+        yield self
+        self._data = archived_settings
+        self._settings_files = archived_settings_files
+        self.external_data = archived_external_data
+
 
 EnvSetting = NamedTuple('EnvSetting', [('name', str), ('value', Mapping[str, Any])])
 

Function to save and restore settings (for testing)
This should allow creating a pytest fixture which undoes all changes to the Settings object after the test is finished.

Instead of a function, a context manager could be used instead.
diff --git a/tests/test_settings.py b/tests/test_settings.py
index 1e6a915..a72b635 100644
--- a/tests/test_settings.py
+++ b/tests/test_settings.py
@@ -244,6 +244,26 @@ def test_filters(mock_empty_os_environ):
     assert dict(settings_map) == {'subsection1': 'test1', 'subsection2': 'test2', 'subsection3': 'test3'}
 
 
+def test_temporary_changes():
+    """Test that temporary changes settings context manager works.
+
+    Within the context, settings should be changeable. After exit, the original
+    settings should be restored.
+
+    """
+    s = settings_parser.Settings()
+    s.update({'a': 1})
+    with s.temporary_changes():
+        # Change the settings within the context
+        s.update({'a': 2, 'b': 2})
+        s.settings_files.append('test')
+        assert s['a'] == 2
+        assert len(s.settings_files) == 1
+    # Check that outside of the context the settings are back to their old state.
+    assert s['a'] == 1
+    assert len(s.settings_files) == 0
+
+
 @pytest.mark.parametrize('use_method', [True, False])
 @pytest.mark.parametrize('option_name', ['config', 'settings'])
 @pytest.mark.parametrize('mode', ['config', 'noconfig', 'wrongfile', 'noclick'])

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-mock pytest-cov toml pyyaml click
3.9
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
click==8.1.8
-e git+https://github.com/daviskirk/climatecontrol.git@26a70d6ca739c452639fe18816bf06ad24e4c4c6#egg=climatecontrol
coverage==7.8.0
exceptiongroup==1.2.2
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
pytest-cov==6.0.0
pytest-mock==3.14.0
PyYAML==6.0.2
toml==0.10.2
tomli==2.2.1
typing==3.7.4.3

name: climatecontrol
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - click==8.1.8
      - coverage==7.8.0
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - pyyaml==6.0.2
      - toml==0.10.2
      - tomli==2.2.1
      - typing==3.7.4.3
prefix: /opt/conda/envs/climatecontrol

tests/test_settings.py::test_temporary_changes
tests/test_settings.py::test_settings[True] tests/test_settings.py::test_settings[None] tests/test_settings.py::test_settings_parse tests/test_settings.py::test_settings_files_and_env_file[.toml] tests/test_settings.py::test_settings_files_and_env_file[.yml] tests/test_settings.py::test_settings_files_and_env_file[.json] tests/test_settings.py::test_settings_files_and_env_file_and_env[.toml] tests/test_settings.py::test_settings_files_and_env_file_and_env[.yml] tests/test_settings.py::test_settings_files_and_env_file_and_env[.json] tests/test_settings.py::test_settings_parsing_order[None-expected0] tests/test_settings.py::test_settings_parsing_order[order1-expected1] tests/test_settings.py::test_settings_parsing_order[order2-expected2] tests/test_settings.py::test_settings_parsing_order[order3-expected3] tests/test_settings.py::test_settings_parsing_order[order4-expected4] tests/test_settings.py::test_update[dict] tests/test_settings.py::test_update[envvar] tests/test_settings.py::test_update[both] tests/test_settings.py::test_filters tests/test_settings.py::test_cli_utils[.toml-wrongfile-config-True] tests/test_settings.py::test_cli_utils[.toml-wrongfile-config-False] tests/test_settings.py::test_cli_utils[.toml-wrongfile-settings-True] tests/test_settings.py::test_cli_utils[.toml-wrongfile-settings-False] tests/test_settings.py::test_cli_utils[.toml-noclick-config-True] tests/test_settings.py::test_cli_utils[.toml-noclick-config-False] tests/test_settings.py::test_cli_utils[.toml-noclick-settings-True] tests/test_settings.py::test_cli_utils[.toml-noclick-settings-False] tests/test_settings.py::test_cli_utils[.yml-wrongfile-config-True] tests/test_settings.py::test_cli_utils[.yml-wrongfile-config-False] tests/test_settings.py::test_cli_utils[.yml-wrongfile-settings-True] tests/test_settings.py::test_cli_utils[.yml-wrongfile-settings-False] tests/test_settings.py::test_cli_utils[.yml-noclick-config-True] tests/test_settings.py::test_cli_utils[.yml-noclick-config-False] tests/test_settings.py::test_cli_utils[.yml-noclick-settings-True] tests/test_settings.py::test_cli_utils[.yml-noclick-settings-False] tests/test_settings.py::test_cli_utils[.json-wrongfile-config-True] tests/test_settings.py::test_cli_utils[.json-wrongfile-config-False] tests/test_settings.py::test_cli_utils[.json-wrongfile-settings-True] tests/test_settings.py::test_cli_utils[.json-wrongfile-settings-False] tests/test_settings.py::test_cli_utils[.json-noclick-config-True] tests/test_settings.py::test_cli_utils[.json-noclick-config-False] tests/test_settings.py::test_cli_utils[.json-noclick-settings-True] tests/test_settings.py::test_cli_utils[.json-noclick-settings-False]
tests/test_settings.py::test_settings_empty tests/test_settings.py::test_settings[False] tests/test_settings.py::test_parse_from_file_vars[False-False] tests/test_settings.py::test_parse_from_file_vars[False-True] tests/test_settings.py::test_parse_from_file_vars[True-False] tests/test_settings.py::test_parse_from_file_vars[True-True] tests/test_settings.py::test_settings_files_fail[asd;kjhaflkjhasf] tests/test_settings.py::test_settings_files_fail[.] tests/test_settings.py::test_settings_files_fail[/home/] tests/test_settings.py::test_settings_files_fail[settings_files3] tests/test_settings.py::test_yaml_import_fail tests/test_settings.py::test_settings_file_content[---\na:\n tests/test_settings.py::test_settings_file_content[{"a": tests/test_settings.py::test_settings_file_content[[a]\nb=5] tests/test_settings.py::test_settings_file_content_fail[a:\n tests/test_settings.py::test_settings_file_content_fail[[{"a": tests/test_settings.py::test_settings_file_content_fail[b=5-SettingsFileError] tests/test_settings.py::test_settings_files_file[.toml] tests/test_settings.py::test_settings_files_file[.yml] tests/test_settings.py::test_settings_files_file[.json] tests/test_settings.py::test_settings_files_files[.toml] tests/test_settings.py::test_settings_files_files[.yml] tests/test_settings.py::test_settings_files_files[.json] tests/test_settings.py::test_assign[settings_files-this.toml-expected0] tests/test_settings.py::test_assign[settings_files-value1-expected1] tests/test_settings.py::test_assign[parser-mock_parser_fcn-mock_parser_fcn] tests/test_settings.py::test_cli_utils[.toml-config-config-True] tests/test_settings.py::test_cli_utils[.toml-config-config-False] tests/test_settings.py::test_cli_utils[.toml-config-settings-True] tests/test_settings.py::test_cli_utils[.toml-config-settings-False] tests/test_settings.py::test_cli_utils[.toml-noconfig-config-True] tests/test_settings.py::test_cli_utils[.toml-noconfig-config-False] tests/test_settings.py::test_cli_utils[.toml-noconfig-settings-True] tests/test_settings.py::test_cli_utils[.toml-noconfig-settings-False] tests/test_settings.py::test_cli_utils[.yml-config-config-True] tests/test_settings.py::test_cli_utils[.yml-config-config-False] tests/test_settings.py::test_cli_utils[.yml-config-settings-True] tests/test_settings.py::test_cli_utils[.yml-config-settings-False] tests/test_settings.py::test_cli_utils[.yml-noconfig-config-True] tests/test_settings.py::test_cli_utils[.yml-noconfig-config-False] tests/test_settings.py::test_cli_utils[.yml-noconfig-settings-True] tests/test_settings.py::test_cli_utils[.yml-noconfig-settings-False] tests/test_settings.py::test_cli_utils[.json-config-config-True] tests/test_settings.py::test_cli_utils[.json-config-config-False] tests/test_settings.py::test_cli_utils[.json-config-settings-True] tests/test_settings.py::test_cli_utils[.json-config-settings-False] tests/test_settings.py::test_cli_utils[.json-noconfig-config-True] tests/test_settings.py::test_cli_utils[.json-noconfig-config-False] tests/test_settings.py::test_cli_utils[.json-noconfig-settings-True] tests/test_settings.py::test_cli_utils[.json-noconfig-settings-False] tests/test_settings.py::test_get_configuration_file[.toml] tests/test_settings.py::test_get_configuration_file[.yml] tests/test_settings.py::test_get_configuration_file[.json]
README.rst climatecontrol/settings_parser.py
README.rst climatecontrol/settings_parser.py