mozilla/configman — pull request #79 by twobraids (2013-08-12 16:25:48+00:00)
Title: make sure required_config is a Mapping and don't try to change it.

When a ConfigurationManger object is created, it takes a Mapping of Option objects. Most frequently, these Option objects come from a class' 'required_config' class variable. An unfortunate side effect is that the ConfigManager instance takes the liberty of changing the value of the default of each Option. This behavior simplifies writing config files and the output of 'help'.

Unfortunately, this has the side effect of changing the default value in the definition of the class. If that class is reused later, the original value of defaults might be lost. This is undesirable especially when running tests: one test will effect the initial state of the next test.

The simple solution is that configman makes a copy of the required_config rather than using the original.

A second bug closely related was also found in tests: if the default value of an Option is a Mock object and that Option uses a class_converter, configman will try to get further 'requried_config' values from that Mock. The Mock will happily comply and return another Mock. This just causes a mess as configman is counting on a failure happen when there is no additional 'requried_config'. The solution here is to make sure that when configman requests a 'requred_config' from an Option, it makes sure that the result is a Mapping object. If it is not, it ignores the result and assumes there is no further 'requried_config'