|
1 | | -from typing import Optional |
2 | | - |
3 | | -from graphql.error import GraphQLSyntaxError |
4 | | -from graphql.language import Source, Lexer, TokenKind |
5 | 1 | from graphql.language.block_string import ( |
6 | 2 | dedent_block_string_value, |
7 | 3 | print_block_string, |
8 | 4 | get_block_string_indentation, |
9 | 5 | ) |
10 | 6 |
|
11 | | -from ..utils import dedent, gen_fuzz_strings |
12 | | - |
13 | 7 |
|
14 | 8 | def join_lines(*args): |
15 | 9 | return "\n".join(args) |
@@ -138,43 +132,3 @@ def correctly_prints_string_with_a_first_line_indentation(): |
138 | 132 | assert print_block_string(s) == join_lines( |
139 | 133 | '"""', " first ", " line ", "indentation", " string", '"""' |
140 | 134 | ) |
141 | | - |
142 | | - def correctly_print_random_strings(): |
143 | | - def lex_value(s: str) -> Optional[str]: |
144 | | - lexer = Lexer(Source(s)) |
145 | | - value = lexer.advance().value |
146 | | - assert lexer.advance().kind == TokenKind.EOF, "Expected EOF" |
147 | | - return value |
148 | | - |
149 | | - # Testing with length >5 is taking exponentially more time. However it is |
150 | | - # highly recommended to test with increased limit if you make any change. |
151 | | - for fuzz_str in gen_fuzz_strings(allowed_chars='\n\t "a\\', max_length=5): |
152 | | - test_str = f'"""{fuzz_str}"""' |
153 | | - |
154 | | - try: |
155 | | - test_value = lex_value(test_str) |
156 | | - except (AssertionError, GraphQLSyntaxError): |
157 | | - continue # skip invalid values |
158 | | - assert isinstance(test_value, str) |
159 | | - |
160 | | - printed_value = lex_value(print_block_string(test_value)) |
161 | | - |
162 | | - assert test_value == printed_value, dedent( |
163 | | - f""" |
164 | | - Expected lex_value(print_block_string({test_value!r}) |
165 | | - to equal {test_value!r} |
166 | | - but got {printed_value!r} |
167 | | - """ |
168 | | - ) |
169 | | - |
170 | | - printed_multiline_string = lex_value( |
171 | | - print_block_string(test_value, " ", True) |
172 | | - ) |
173 | | - |
174 | | - assert test_value == printed_multiline_string, dedent( |
175 | | - f""" |
176 | | - Expected lex_value(print_block_string({test_value!r}, ' ', True) |
177 | | - to equal {test_value!r} |
178 | | - but got {printed_multiline_string!r} |
179 | | - """ |
180 | | - ) |
0 commit comments