Changeset 199:b796e986ac3b for imapclient
- Timestamp:
- 01/25/11 17:48:43 (16 months ago)
- Branch:
- default
- Files:
-
- 1 modified
-
imapclient/test/test_response_parser.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
imapclient/test/test_response_parser.py
r198 r199 24 24 from imapclient.response_parser import parse_response, parse_fetch_response, ParseError 25 25 from imapclient.test.util import unittest 26 from pprint import pformat27 26 28 27 #TODO: tokenising tests … … 161 160 162 161 def test_incomplete_tuple(self): 163 self._test_parse_error('abc (1 2', 'Tuple incomplete before " (1 2"')162 self._test_parse_error('abc (1 2', 'Tuple incomplete before "\(1 2"') 164 163 165 164 def test_incomplete_juxtaposed_tuples(self): 166 165 self._test_parse_error('(1 2)(3 4', 167 'Juxtaposed tuples incomplete before " (1 2)(3 4"')166 'Juxtaposed tuples incomplete before "\(1 2\)\(3 4"') 168 167 169 168 def test_bad_literal(self): … … 173 172 174 173 def test_bad_quoting(self): 175 self._test_parse_error('"abc next', " No closing '\"'")174 self._test_parse_error('"abc next', """No closing '"'""") 176 175 177 176 … … 183 182 to_parse = [to_parse] 184 183 output = parse_response(to_parse) 185 self.assert_(output == expected, 186 format_error(to_parse, output, expected)) 184 self.assertSequenceEqual(output, expected) 187 185 188 186 def _test_parse_error(self, to_parse, expected_msg): 189 187 if not isinstance(to_parse, list): 190 188 to_parse = [to_parse] 191 try: 192 parse_response(to_parse) 193 self.fail("didn't raise an exception") 194 except ParseError, err: 195 actual_msg = str(err) 196 self.assert_(expected_msg == actual_msg[:len(expected_msg)], 197 'got ParseError with wrong msg: %r' % actual_msg) 198 189 self.assertRaisesRegexp(ParseError, expected_msg, 190 parse_response, to_parse) 199 191 200 192 … … 332 324 333 325 334 335 def format_error(input_, output, expected):336 return 'failed for:\n%s\ngot:\n%s\nexpected:\n%s' % (337 pformat(input_),338 pformat(output),339 pformat(expected))340 341 342 326 def add_crlf(text): 343 327 return CRLF.join(text.splitlines()) + CRLF … … 349 333 350 334 351 if __name__ == '__main__':352 unittest.main()
