Bug 1100363 - Maintain preference case. r=whimboo
authorUjjwal Wahi <w.ujjwal@gmail.com>
Wed, 07 Jan 2015 14:30:51 +0100
changeset 235466 02b4ccc6cc9109f71f44d61528d474f9b16a21e2
parent 235465 e4a35e6a726ed3f5622bcab58e62f0e853682a97
child 235467 7a5175e8ba699c91751d9dcff9f4c2dd8bb54d11
push id366
push usercmanchester@mozilla.com
push dateThu, 08 Jan 2015 16:40:24 +0000
reviewerswhimboo
bugs1100363
milestone37.0a1
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)