Skip to content

Commit 5795d76

Browse files
committed
Add unit test for dump_config auto format detection
1 parent 4a06987 commit 5795d76

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/toast/config/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ def dump_config(file, conf, format=None, comm=None):
100100
if format is None:
101101
# Guess from the file name
102102
base, ext = os.path.splitext(file)
103-
if ext == "toml":
103+
if ext == ".toml":
104104
format = "toml"
105-
elif ext == "json" or ext == "jsn":
105+
elif ext == ".json" or ext == ".jsn":
106106
format = "json"
107-
elif ext == "yaml" or ext == "yml":
107+
elif ext == ".yaml" or ext == ".yml":
108108
format = "yaml"
109109
else:
110110
msg = "Cannot determine format (yaml, toml, json) from"

src/toast/tests/config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,19 @@ def test_config_multi(self):
451451
if self.toastcomm.comm_world is not None:
452452
self.toastcomm.comm_world.barrier()
453453

454+
conf_defaults_auto_file = os.path.join(
455+
self.outdir, f"multi_defaults_auto.{case}"
456+
)
457+
if self.toastcomm.world_rank == 0:
458+
dump_config(
459+
conf_defaults_auto_file,
460+
defaults,
461+
format=None,
462+
comm=self.toastcomm.comm_world,
463+
)
464+
if self.toastcomm.comm_world is not None:
465+
self.toastcomm.comm_world.barrier()
466+
454467
# Now change some values
455468
testops["mem_count"].prefix = "newpref"
456469
testops["mem_count"].enabled = False

0 commit comments

Comments
 (0)