Bug 1100363 - Maintain preference case. r=whimboo
--- a/testing/mozbase/mozprofile/mozprofile/prefs.py
+++ b/testing/mozbase/mozprofile/mozprofile/prefs.py
@@ -112,16 +112,17 @@ class Preferences(object):
raise PreferencesReadError("Could not recognize format of %s" % path)
@classmethod
def read_ini(cls, path, section=None):
"""read preferences from an .ini file"""
parser = ConfigParser()
+ parser.optionxform = str
parser.readfp(mozfile.load(path))
if section:
if section not in parser.sections():
raise PreferencesReadError("No section '%s' in %s" % (section, path))
retval = parser.items(section, raw=True)
else:
retval = parser.defaults().items()
--- a/testing/mozbase/mozprofile/tests/test_preferences.py
+++ b/testing/mozbase/mozprofile/tests/test_preferences.py
@@ -101,16 +101,39 @@ browser.startup.homepage = http://github
_prefs = {'browser.startup.homepage': 'http://github.com/'}
commandline[-1] = commandline[-1] + ':foo'
self.compare_generated(_prefs, commandline)
finally:
# cleanup
os.remove(name)
+ def test_ini_keep_case(self):
+ """
+ Read a preferences config file with a preference in camel-case style.
+ Check that the read preference name has not been lower-cased
+ """
+ # write the .ini file
+ _ini = """[DEFAULT]
+general.warnOnAboutConfig = False
+"""
+ try:
+ fd, name = tempfile.mkstemp(suffix='.ini')
+ os.write(fd, _ini)
+ os.close(fd)
+ commandline = ["--preferences", name]
+
+ # test the [DEFAULT] section
+ _prefs = {'general.warnOnAboutConfig': 'False'}
+ self.compare_generated(_prefs, commandline)
+
+ finally:
+ # cleanup
+ os.remove(name)
+
def test_reset_should_remove_added_prefs(self):
"""Check that when we call reset the items we expect are updated"""
profile = Profile()
prefs_file = os.path.join(profile.profile, 'user.js')
# we shouldn't have any initial preferences
initial_prefs = Preferences.read_prefs(prefs_file)
self.assertFalse(initial_prefs)