From 44568da45447372f21e2097f8ebc39f4f8ef6997 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Thu, 27 Jun 2024 19:40:17 +0100 Subject: [PATCH 1/2] Use a temporary file for the application_preferences_filename --- .../preferences/tests/test_scoped_preferences.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apptools/preferences/tests/test_scoped_preferences.py b/apptools/preferences/tests/test_scoped_preferences.py index c6b2c71e..0d4cdb1a 100644 --- a/apptools/preferences/tests/test_scoped_preferences.py +++ b/apptools/preferences/tests/test_scoped_preferences.py @@ -42,14 +42,18 @@ class ScopedPreferencesTestCase(PreferencesTestCase): def setUp(self): """ Prepares the test fixture before each test method is called. """ - self.preferences = ScopedPreferences() + # A temporary directory that can safely be written to. + self.tmpdir = tempfile.mkdtemp() + + self.preferences = ScopedPreferences( + application_preferences_filename=os.path.join( + self.tmpdir, "preferences.ini" + ) + ) # The filename of the example preferences file. self.example = os.fspath(files(PKG) / "example.ini") - # A temporary directory that can safely be written to. - self.tmpdir = tempfile.mkdtemp() - def tearDown(self): """ Called immediately after each test method has been called. """ From e13935b0135b1e752dcf8a93a4765eee56c622d9 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Thu, 27 Jun 2024 21:09:06 +0100 Subject: [PATCH 2/2] One more fix to avoid tests from touching the filesystem --- apptools/preferences/tests/test_preferences_helper.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apptools/preferences/tests/test_preferences_helper.py b/apptools/preferences/tests/test_preferences_helper.py index 1c27c21f..777a71d7 100644 --- a/apptools/preferences/tests/test_preferences_helper.py +++ b/apptools/preferences/tests/test_preferences_helper.py @@ -411,7 +411,9 @@ class AcmeUIPreferencesHelper(PreferencesHelper): def test_scoped_preferences(self): """ scoped preferences """ - p = set_default_preferences(ScopedPreferences()) + p = set_default_preferences( + ScopedPreferences(application_preferences_filename=self.tmpfile) + ) # Set a preference value in the default scope. p.set("default/acme.ui.bgcolor", "blue")