Skip to content
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: 2 additions & 2 deletions openml/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _setup(config=None):
# read config file, create directory for config file
if not os.path.exists(config_dir):
try:
os.mkdir(config_dir)
os.makedirs(config_dir, exist_ok=True)
cache_exists = True
except PermissionError:
cache_exists = False
Expand Down Expand Up @@ -235,7 +235,7 @@ def _get(config, key):
# create the cache subdirectory
if not os.path.exists(cache_directory):
try:
os.mkdir(cache_directory)
os.makedirs(cache_directory, exist_ok=True)
except PermissionError:
openml_logger.warning(
"No permission to create openml cache directory at %s! This can result in "
Expand Down
10 changes: 10 additions & 0 deletions tests/test_openml/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ def test_non_writable_home(self, log_handler_mock, warnings_mock, expanduser_moc
self.assertEqual(log_handler_mock.call_count, 1)
self.assertFalse(log_handler_mock.call_args_list[0][1]["create_file_handler"])

@unittest.mock.patch("os.path.expanduser")
def test_XDG_directories_do_not_exist(self, expanduser_mock):
with tempfile.TemporaryDirectory(dir=self.workdir) as td:

def side_effect(path_):
return os.path.join(td, str(path_).replace("~/", ""))

expanduser_mock.side_effect = side_effect
openml.config._setup()

def test_get_config_as_dict(self):
""" Checks if the current configuration is returned accurately as a dict. """
config = openml.config.get_config_as_dict()
Expand Down