@@ -101,4 +101,28 @@ def test_base(self):
101
101
# it raises if there is no default though
102
102
self .failUnlessRaises (NoSectionError , r_config .get_value , "doesnt" , "exist" )
103
103
104
-
104
+ def test_values (self ):
105
+ file_obj = self ._to_memcache (fixture_path ("git_config_values" ))
106
+ w_config = GitConfigParser (file_obj , read_only = False )
107
+ w_config .write () # enforce writing
108
+ orig_value = file_obj .getvalue ()
109
+
110
+ # Reading must unescape backslashes
111
+ backslash = w_config .get ('values' , 'backslash' )
112
+ assert backslash == r'some\data'
113
+
114
+ # Reading must unescape quotes
115
+ quote = w_config .get ('values' , 'quote' )
116
+ assert quote == 'this is a "quoted value"'
117
+
118
+ # Reading must remove surrounding quotes
119
+ quoted = w_config .get ('values' , 'quoted' )
120
+ assert quoted == 'all your "quotes" are belong to us'
121
+
122
+ # Writing must escape backslashes and quotes
123
+ w_config .set ('values' , 'backslash' , backslash )
124
+ w_config .set ('values' , 'quote' , quote )
125
+ w_config .write () # enforce writing
126
+
127
+ # Contents shouldn't differ
128
+ assert file_obj .getvalue () == orig_value
0 commit comments