42
42
def lex_value (s : str ) -> Optional [str ]:
43
43
lexer = Lexer (Source (s ))
44
44
value = lexer .advance ().value
45
- assert lexer .advance ().kind == TokenKind .EOF
45
+ assert lexer .advance ().kind == TokenKind .EOF , "Expected EOF"
46
46
return value
47
47
48
48
@@ -53,15 +53,23 @@ def __init__(self, doc_string: str):
53
53
def to_equal (self , expected : str ):
54
54
doc_string = self .doc_string
55
55
stripped = strip_ignored_characters (doc_string )
56
- assert stripped == expected , (
57
- f"Expected strip_ignored_characters({ doc_string !r} )\n "
58
- f"\t to equal { expected !r} \n \t but got { stripped !r} "
56
+
57
+ assert stripped == expected , dedent (
58
+ f"""
59
+ Expected strip_ignored_characters({ doc_string !r} )
60
+ to equal { expected !r}
61
+ but got { stripped !r}
62
+ """
59
63
)
60
64
61
65
stripped_twice = strip_ignored_characters (stripped )
62
- assert stripped == stripped_twice , (
63
- f"Expected strip_ignored_characters({ stripped !r} )\n "
64
- f"\t to equal { stripped !r} \n \t but got { stripped_twice !r} "
66
+
67
+ assert stripped == stripped_twice , dedent (
68
+ f""""
69
+ Expected strip_ignored_characters({ stripped !r} )"
70
+ to equal { stripped !r}
71
+ but got { stripped_twice !r}
72
+ """
65
73
)
66
74
67
75
def to_stay_the_same (self ):
@@ -338,7 +346,13 @@ def expect_stripped_string(block_str: str):
338
346
stripped_str = strip_ignored_characters (block_str )
339
347
stripped_value = lex_value (stripped_str )
340
348
341
- assert original_value == stripped_value
349
+ assert original_value == stripped_value , dedent (
350
+ f"""
351
+ Expected lexOne(stripIgnoredCharacters({ block_str !r} )
352
+ to equal { original_value !r}
353
+ but got { stripped_value !r}
354
+ """
355
+ )
342
356
return ExpectStripped (block_str )
343
357
344
358
expect_stripped_string ('""""""' ).to_stay_the_same ()
@@ -389,7 +403,13 @@ def expect_stripped_string(block_str: str):
389
403
stripped_str = strip_ignored_characters (test_str )
390
404
stripped_value = lex_value (stripped_str )
391
405
392
- assert test_value == stripped_value
406
+ assert test_value == stripped_value , dedent (
407
+ f"""
408
+ Expected lexOne(stripIgnoredCharacters({ test_str !r} )
409
+ to equal { test_value !r}
410
+ but got { stripped_value !r}
411
+ """
412
+ )
393
413
394
414
# noinspection PyShadowingNames
395
415
def strips_kitchen_sink_query_but_maintains_the_exact_same_ast (
0 commit comments