diff --git a/pygmt/src/config.py b/pygmt/src/config.py index 0fcf181891c..0bedf9fe091 100644 --- a/pygmt/src/config.py +++ b/pygmt/src/config.py @@ -207,7 +207,7 @@ def __enter__(self): def __exit__(self, exc_type, exc_value, traceback): # revert to initial values arg_str = " ".join( - [f"{key}={value}" for key, value in self.old_defaults.items()] + [f'{key}="{value}"' for key, value in self.old_defaults.items()] ) with Session() as lib: lib.call_module(module="set", args=arg_str) diff --git a/pygmt/tests/test_config.py b/pygmt/tests/test_config.py index a1e591e8220..fbaddd323e4 100644 --- a/pygmt/tests/test_config.py +++ b/pygmt/tests/test_config.py @@ -72,8 +72,13 @@ def test_config_format_date_map(): Note the space in 'o dd', this acts as a regression test for https://github.com/GenericMappingTools/pygmt/issues/247. + + Setting FORMAT_DATE_MAP="yyyy mm dd" as a regression test for + https://github.com/GenericMappingTools/pygmt/issues/2298. """ fig = Figure() + # Set FORMAT_DATE_MAP to "yyyy mm dd" which contains whitespaces. + config(FORMAT_DATE_MAP="yyyy mm dd") with config(FORMAT_DATE_MAP="o dd"): fig.basemap( region=["1969-7-21T", "1969-7-23T", 0, 1],