Browse Source

grass.gunittest: Fix fail with no config (#2180)

Adds an empty section to the parser when no config file is available and returning the section proxy instead of returning and empty dict which has a different API than the section proxy.

Fixes an issue introduced in #2172 which shows in grass-addons CI.
Vaclav Petras 2 years ago
parent
commit
1ece3bc558
1 changed files with 4 additions and 1 deletions
  1. 4 1
      python/grass/gunittest/main.py

+ 4 - 1
python/grass/gunittest/main.py

@@ -137,9 +137,12 @@ def get_config(start_directory):
     config_file = Path(start_directory) / CONFIG_FILENAME
     if config_file.is_file():
         config_parser.read(config_file)
+    else:
+        # Create an empty section if file is not available.
+        config_parser.read_dict({"gunittest": {}})
     if "gunittest" in config_parser:
         return config_parser["gunittest"]
-    return {}
+    return config_parser
 
 
 def main():