(self)
| 263 | assert cap_logger.out == "" |
| 264 | |
| 265 | def test_use_default_values(self): |
| 266 | # let's first save a config that should be in the form |
| 267 | # a=2, |
| 268 | # b=5, |
| 269 | # c=(2, 5), |
| 270 | # d="for diffusion", |
| 271 | # e=[1, 3], |
| 272 | |
| 273 | config = SampleObject() |
| 274 | |
| 275 | config_dict = {k: v for k, v in config.config.items() if not k.startswith("_")} |
| 276 | |
| 277 | # make sure that default config has all keys in `_use_default_values` |
| 278 | assert set(config_dict.keys()) == set(config.config._use_default_values) |
| 279 | |
| 280 | with tempfile.TemporaryDirectory() as tmpdirname: |
| 281 | config.save_config(tmpdirname) |
| 282 | |
| 283 | # now loading it with SampleObject2 should put f into `_use_default_values` |
| 284 | config = SampleObject2.from_config(SampleObject2.load_config(tmpdirname)) |
| 285 | |
| 286 | assert "f" in config.config._use_default_values |
| 287 | assert config.config.f == [1, 3] |
| 288 | |
| 289 | # now loading the config, should **NOT** use [1, 3] for `f`, but the default [1, 4] value |
| 290 | # **BECAUSE** it is part of `config.config._use_default_values` |
| 291 | new_config = SampleObject4.from_config(config.config) |
| 292 | assert new_config.config.f == [5, 4] |
| 293 | |
| 294 | config.config._use_default_values.pop() |
| 295 | new_config_2 = SampleObject4.from_config(config.config) |
| 296 | assert new_config_2.config.f == [1, 3] |
| 297 | |
| 298 | # Nevertheless "e" should still be correctly loaded to [1, 3] from SampleObject2 instead of defaulting to [1, 5] |
| 299 | assert new_config_2.config.e == [1, 3] |
| 300 | |
| 301 | def test_check_path_types(self): |
| 302 | # Verify that we get a string returned from a WindowsPath or PosixPath (depending on system) |
nothing calls this directly
no test coverage detected