Bug 1100363 - Maintain preference case. r=whimboo
authorUjjwal Wahi <w.ujjwal@gmail.com>
Wed, 07 Jan 2015 14:30:51 +0100
changeset 222493 02b4ccc6cc9109f71f44d61528d474f9b16a21e2
parent 222492 e4a35e6a726ed3f5622bcab58e62f0e853682a97
child 222494 7a5175e8ba699c91751d9dcff9f4c2dd8bb54d11
push id28067
push userkwierso@gmail.com
push dateWed, 07 Jan 2015 23:41:38 +0000
treeherdermozilla-central@70de2960aa87 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1100363
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1100363 - Maintain preference case. r=whimboo
testing/mozbase/mozprofile/mozprofile/prefs.py
testing/mozbase/mozprofile/tests/test_preferences.py
--- 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)