comparison mercurial/templater.py @ 45886:18489e26d9a0

tests: make doctests not depend on str(ParseError()) format `ParseError` implements `__bytes__`, but it doesn't implement `__str__`, so it gets the default `__str__` implementation. The next patch will make it so `ParseError` gets a `__str__` implementation, which changes the format slightly. This prepares by making us not depend on the format. Differential Revision: https://phab.mercurial-scm.org/D9349
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 20 Nov 2020 13:24:45 -0800
parents 0fc8b066928a
children 89a2afe31e82
comparison
equal deleted inserted replaced
45885:600aec73f309 45886:18489e26d9a0
374 374
375 >>> parseexpr(b'"foo"') 375 >>> parseexpr(b'"foo"')
376 ('string', 'foo') 376 ('string', 'foo')
377 >>> parseexpr(b'foo(bar)') 377 >>> parseexpr(b'foo(bar)')
378 ('func', ('symbol', 'foo'), ('symbol', 'bar')) 378 ('func', ('symbol', 'foo'), ('symbol', 'bar'))
379 >>> parseexpr(b'foo(') 379 >>> from . import error
380 Traceback (most recent call last): 380 >>> from . import pycompat
381 ... 381 >>> try:
382 ParseError: ('not a prefix: end', 4) 382 ... parseexpr(b'foo(')
383 >>> parseexpr(b'"foo" "bar"') 383 ... except error.ParseError as e:
384 Traceback (most recent call last): 384 ... pycompat.sysstr(e.message)
385 ... 385 ... e.location
386 ParseError: ('invalid token', 7) 386 'not a prefix: end'
387 4
388 >>> try:
389 ... parseexpr(b'"foo" "bar"')
390 ... except error.ParseError as e:
391 ... pycompat.sysstr(e.message)
392 ... e.location
393 'invalid token'
394 7
387 """ 395 """
388 try: 396 try:
389 return _parseexpr(expr) 397 return _parseexpr(expr)
390 except error.ParseError as inst: 398 except error.ParseError as inst:
391 _addparseerrorhint(inst, expr) 399 _addparseerrorhint(inst, expr)