Commits

Michael Foord  committed e4d6ef5

Accessing a non-existent config file section now creates it in the data structure rather than just returning a detached Section

  • Participants
  • Parent commits e810ea7
  • Branches plugins

Comments (0)

Files changed (1)

File unittest2/config.py

     # warning! mutable
     if section is None:
         return _config
-    return _config.get(section, Section(section))
+    return _config.setdefault(section, Section(section))
 
 
 def combineConfigs(parsers):
 
     def as_str(self, item, default=DEFAULT):
         value = self._get_value(item, default, allowEmpty=True)
-        if value is DEFAULT:
+        if value is RETURN_DEFAULT:
             return default
         return value
 
     def as_list(self, item, default=DEFAULT):
         value = self._get_value(item, default, allowEmpty=True)
-        if value is DEFAULT:
+        if value is RETURN_DEFAULT:
             return default
         return [line.strip() for line in value.splitlines()
                  if line.strip() and not line.strip().startswith('#')]