@@ -186,5 +186,35 @@ def test_formatdate_with_localtime(self):
186186 string = utils .formatdate (timeval , localtime = True )
187187 self .assertEqual (string , 'Thu, 01 Dec 2011 18:00:00 +0300' )
188188
189+ class UnquoteTests (unittest .TestCase ):
190+
191+ def test_unquote_basic (self ):
192+ self .assertEqual (utils .unquote ('"value"' ), 'value' )
193+
194+ def test_unquote_with_trailing_garbage (self ):
195+ self .assertEqual (utils .unquote ('"bound"\n \t X-Priority: 3' ), 'bound' )
196+
197+ def test_unquote_with_escaped_quote (self ):
198+ self .assertEqual (utils .unquote (r'"val\"ue"' ), 'val"ue' )
199+
200+ def test_unquote_with_escaped_backslash (self ):
201+ self .assertEqual (utils .unquote (r'"val\\ue"' ), r'val\ue' )
202+
203+ def test_unquote_angle_brackets (self ):
204+ self .assertEqual (utils .unquote ('<value>' ), 'value' )
205+
206+ def test_unquote_no_quotes (self ):
207+ self .assertEqual (utils .unquote ('value' ), 'value' )
208+
209+ def test_unquote_single_char (self ):
210+ self .assertEqual (utils .unquote ('v' ), 'v' )
211+
212+ def test_unquote_empty_quoted (self ):
213+ self .assertEqual (utils .unquote ('""' ), '' )
214+
215+ def test_unquote_mixed_escapes (self ):
216+ self .assertEqual (utils .unquote (r'"a\\b\"c"' ), r'a\b"c' )
217+
218+
189219if __name__ == '__main__' :
190220 unittest .main ()
0 commit comments