Skip to content

Commit

Permalink
comment to draw attention to the automatically applied test fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
backmari committed Nov 7, 2024
1 parent b4906da commit 90feaf7
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@
this_module_path = sys.modules[__name__].__file__


################################################
# FIXTURES AUTOMATICALLY APPLIED TO EVERY TEST #
################################################


@pytest.fixture(autouse=True)
def qsettings_tmp_path(tmp_path):
"""
Set the location of the config file generated by QSettings to a temporary directory
This avoids:
- unit tests affecting the local user settings in ~/.config/.refredm.conf and vice versa
- settings spilling over between tests by having a unique settings file location in each test
(thanks to `tmp_path` creating a unique directory for each test)
"""
QSettings.setPath(QSettings.NativeFormat, QSettings.UserScope, str(tmp_path))


##################################
# FIXTURES THAT CAN BE REQUESTED #
##################################


@pytest.fixture(scope="session")
def DATA_DIR():
return Path(__file__).parent / "data"
Expand Down Expand Up @@ -86,16 +109,3 @@ def get_file_paths(self, number):
return file_list

return _DataServe()


@pytest.fixture(autouse=True)
def qsettings_tmp_path(tmp_path):
"""
Set the location of the config file generated by QSettings to a temporary directory
This avoids:
- unit tests affecting the local user settings in ~/.config/.refredm.conf and vice versa
- settings spilling over between tests by having a unique settings file location in each test
(thanks to `tmp_path` creating a unique directory for each test)
"""
QSettings.setPath(QSettings.NativeFormat, QSettings.UserScope, str(tmp_path))

0 comments on commit 90feaf7

Please sign in to comment.