Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a temporary file for the application_preferences_filename #338

Merged
merged 4 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apptools/preferences/tests/test_preferences_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 8 additions & 4 deletions apptools/preferences/tests/test_scoped_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. """

Expand Down
Loading