Skip to content

Commit a53947e

Browse files
committed
syntax-highlight source code in test output
1 parent 4f85957 commit a53947e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

unpythonic/syntax/testingtools.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ def _test_expr(tree):
823823
# For this reason, we provide `with expand_testing_macros_first`, which
824824
# in itself is a code-walking block macro, whose only purpose is to force
825825
# `test[]` and its sisters to expand first.)
826-
sourcecode = unparse(tree)
826+
sourcecode = unparse(tree, color=True, expander=dyn._macro_expander)
827827

828828
envname = gensym("e") # for injecting the captured value
829829

@@ -866,7 +866,7 @@ def _record_value(envname, sourcecode, value):
866866
def _inject_value_recorder(envname, tree): # wrap tree with the the[] handler
867867
recorder = q[h[_record_value]] # TODO: stash hygienic value?
868868
return q[a[recorder](n[envname],
869-
u[unparse(tree)],
869+
u[unparse(tree, color=True, expander=dyn._macro_expander)],
870870
a[tree])]
871871
def _transform_important_subexpr(tree, envname):
872872
# The the[] mark mechanism is invoked outside-in, because for reporting,
@@ -915,7 +915,7 @@ def _test_expr_signals_or_raises(tree, syntaxname, asserter):
915915
raise SyntaxError(f"Expected one of {syntaxname}[exctype, expr], {syntaxname}[exctype, expr, message]") # pragma: no cover
916916

917917
# Same remark about outside-in source code capture as in `_test_expr`.
918-
sourcecode = unparse(tree)
918+
sourcecode = unparse(tree, color=True, expander=dyn._macro_expander)
919919

920920
# Name our lambda to make the stack trace more understandable.
921921
# For consistency, the name matches that used by `_test_expr`.
@@ -952,7 +952,7 @@ def _test_block(block_body, args):
952952
raise SyntaxError('Expected `with test:` or `with test[message]:`') # pragma: no cover
953953

954954
# Same remark about outside-in source code capture as in `_test_expr`.
955-
sourcecode = unparse(block_body)
955+
sourcecode = unparse(block_body, color=True, expander=dyn._macro_expander)
956956

957957
envname = gensym("e") # for injecting the captured value
958958

@@ -1024,7 +1024,7 @@ def _test_block_signals_or_raises(block_body, args, syntaxname, asserter):
10241024
raise SyntaxError(f'Expected `with {syntaxname}(exctype):` or `with {syntaxname}[exctype, message]:`') # pragma: no cover
10251025

10261026
# Same remark about outside-in source code capture as in `_test_expr`.
1027-
sourcecode = unparse(block_body)
1027+
sourcecode = unparse(block_body, color=True, expander=dyn._macro_expander)
10281028

10291029
testblock_function_name = gensym("_test_block")
10301030
thetest = q[(a[asserter])(a[exctype],

0 commit comments

Comments
 (0)