Skip to content
Prev Previous commit
Next Next commit
fix: skip test for WSL as it is not supported
  • Loading branch information
LennartPurucker committed Oct 14, 2024
commit 0b1bcdd296b5141038fa6bc186ec7e42b0de6b05
12 changes: 9 additions & 3 deletions tests/test_openml/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import unittest.mock
from copy import copy
from pathlib import Path
import platform

import pytest

Expand All @@ -17,14 +18,18 @@ class TestConfig(openml.testing.TestBase):
@unittest.mock.patch("openml.config.openml_logger.warning")
@unittest.mock.patch("openml.config._create_log_handlers")
@unittest.skipIf(os.name == "nt", "https://github.com/openml/openml-python/issues/1033")
@unittest.skipIf(
platform.uname().release.endswith(("-Microsoft", "microsoft-standard-WSL2")),
"WSL does nto support chmod as we would need here, see https://github.com/microsoft/WSL/issues/81",
)
def test_non_writable_home(self, log_handler_mock, warnings_mock):
with tempfile.TemporaryDirectory(dir=self.workdir) as td:
os.chmod(td, 0o444)
_dd = copy(openml.config._defaults)
_dd["cachedir"] = Path(td) / "something-else"
openml.config._setup(_dd)

assert warnings_mock.call_count == 2
assert warnings_mock.call_count == 1
assert log_handler_mock.call_count == 1
assert not log_handler_mock.call_args_list[0][1]["create_file_handler"]
assert openml.config._root_cache_directory == Path(td) / "something-else"
Expand Down Expand Up @@ -121,7 +126,7 @@ def test_example_configuration_start_twice(self):


def test_configuration_file_not_overwritten_on_load():
""" Regression test for #1337 """
"""Regression test for #1337"""
config_file_content = "apikey = abcd"
with tempfile.TemporaryDirectory() as tmpdir:
config_file_path = Path(tmpdir) / "config"
Expand All @@ -136,9 +141,10 @@ def test_configuration_file_not_overwritten_on_load():
assert config_file_content == new_file_content
assert "abcd" == read_config["apikey"]


def test_configuration_loads_booleans(tmp_path):
config_file_content = "avoid_duplicate_runs=true\nshow_progress=false"
with (tmp_path/"config").open("w") as config_file:
with (tmp_path / "config").open("w") as config_file:
config_file.write(config_file_content)
read_config = openml.config._parse_config(tmp_path)

Expand Down