Skip to content

Commit ae4aadb

Browse files
authored
pygmt.config: Correctly resetting to default values that contain whitespaces (#2331)
1 parent 9039636 commit ae4aadb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pygmt/src/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def __enter__(self):
207207
def __exit__(self, exc_type, exc_value, traceback):
208208
# revert to initial values
209209
arg_str = " ".join(
210-
[f"{key}={value}" for key, value in self.old_defaults.items()]
210+
[f'{key}="{value}"' for key, value in self.old_defaults.items()]
211211
)
212212
with Session() as lib:
213213
lib.call_module(module="set", args=arg_str)

pygmt/tests/test_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ def test_config_format_date_map():
7272
7373
Note the space in 'o dd', this acts as a regression test for
7474
https://github.com/GenericMappingTools/pygmt/issues/247.
75+
76+
Setting FORMAT_DATE_MAP="yyyy mm dd" as a regression test for
77+
https://github.com/GenericMappingTools/pygmt/issues/2298.
7578
"""
7679
fig = Figure()
80+
# Set FORMAT_DATE_MAP to "yyyy mm dd" which contains whitespaces.
81+
config(FORMAT_DATE_MAP="yyyy mm dd")
7782
with config(FORMAT_DATE_MAP="o dd"):
7883
fig.basemap(
7984
region=["1969-7-21T", "1969-7-23T", 0, 1],

0 commit comments

Comments
 (0)