| 1 | ||
| 2 | import sys, pytest, collections, collections.abc, urllib3.exceptions, _pytest.pytester, numpy; | |
| 3 | collections.Mapping = collections.abc.Mapping; | |
| 4 | collections.MutableMapping = collections.abc.MutableMapping; | |
| 5 | collections.MutableSet = collections.abc.MutableSet; | |
| 6 | collections.Sequence = collections.abc.Sequence; | |
| 7 | collections.Callable = collections.abc.Callable; | |
| 8 | collections.Iterable = collections.abc.Iterable; | |
| 9 | collections.Iterator = collections.abc.Iterator; | |
| 10 | urllib3.exceptions.SNIMissingWarning = urllib3.exceptions.DependencyWarning; | |
| 11 | pytest.RemovedInPytest4Warning = DeprecationWarning; | |
| 12 | _pytest.pytester.Testdir = _pytest.pytester.Pytester; | |
| 13 | numpy.PINF = numpy.inf; | |
| 14 | numpy.unicode_ = numpy.str_; | |
| 15 | numpy.bytes_ = numpy.bytes_; | |
| 16 | numpy.float_ = numpy.float64; | |
| 17 | numpy.string_ = numpy.bytes_; | |
| 18 | numpy.NaN = numpy.nan; | |
| 19 | ||
| 20 | ||
| 21 | from main import parse, SgfTree, _process_text | |
| 22 | ||
| 23 | # Debug the specific failing test case | |
| 24 | input_str = "(;A[\\]B[c\\d])" | |
| 25 | print("Input string:", repr(input_str)) | |
| 26 | ||
| 27 | # Let's manually trace what happens during parsing | |
| 28 | content = input_str[1:-1] # Remove outer parentheses | |
| 29 | print("Content after removing ():", repr(content)) | |
| 30 | ||
| 31 | # Manual parsing trace | |
| 32 | index = 0 | |
| 33 | print(f"Starting at index {index}: {repr(content[index])}") | |
| 34 | ||
| 35 | # Skip semicolon | |
| 36 | if content[index] == ';': | |
| 37 | index += 1 | |
| 38 | print(f"Skipped semicolon, now at index {index}") | |
| 39 | ||
| 40 | # Parse first property key | |
| 41 | key_start = index | |
| 42 | while index < len(content) and content[index].isalpha(): | |
| 43 | print(f"At index {index}: {repr(content[index])} (part of key)") | |
| 44 | index += 1 | |
| 45 | ||
| 46 | key1 = content[key_start:index] | |
| 47 | print(f"First key: {repr(key1)} (indices {key_start}-{index})") | |
| 48 | ||
| 49 | # Parse first property values | |
| 50 | values1 = [] | |
| 51 | while index < len(content) and content[index] == '[': | |
| 52 | print(f"At index {index}: {repr(content[index])} (opening bracket)") | |
| 53 | index += 1 # Skip '[' | |
| 54 | value_start = index | |
| 55 | print(f"Value starts at index {value_start}") | |
| 56 | ||
| 57 | # Parse value - this is where the issue likely is | |
| 58 | while index < len(content): | |
| 59 | print(f" Value parsing at index {index}: {repr(content[index])}") | |
| 60 | if content[index] == ']': | |
| 61 | # Check if this ] is escaped | |
| 62 | backslash_count = 0 | |
| 63 | check_index = index - 1 | |
| 64 | while check_index >= value_start and content[check_index] == '\\': | |
| 65 | backslash_count += 1 | |
| 66 | check_index -= 1 | |
| 67 | ||
| 68 | print(f" Found ], backslash count before it: {backslash_count}") | |
| 69 | if backslash_count % 2 == 0: | |
| 70 | print(" This ] is NOT escaped, breaking") | |
| 71 | break | |
| 72 | else: | |
| 73 | print(" This ] is escaped, continuing") | |
| 74 | index += 1 | |
| 75 | elif content[index] == '\\': | |
| 76 | print(f" Found \\, skipping to index {index+2}") | |
| 77 | index += 2 | |
| 78 | else: | |
| 79 | print(f" Regular character, moving to next") | |
| 80 | index += 1 | |
| 81 | ||
| 82 | value1 = content[value_start:index] | |
| 83 | print(f"First value: {repr(value1)} (indices {value_start}-{index})") | |
| 84 | processed_value1 = _process_text(value1) | |
| 85 | print(f"Processed first value: {repr(processed_value1)}") | |
| 86 | values1.append(processed_value1) | |
| 87 | index += 1 # Skip ']' | |
| 88 | print(f"After closing bracket, index: {index}") | |
| 89 | ||
| 90 | print(f"First property complete: {repr(key1)} = {repr(values1)}") | |
| 91 | print(f"Next character: {repr(content[index]) if index < len(content) else 'END'}") |
| Test Name | Status |
|---|---|
test_escaped_t_and_n_in_property_value_are_just_letters_not_whitespace | Fail |
test_all_lowercase_property | Pass |
test_empty_input | Pass |
test_escaped_backslash_in_property_value_becomes_just_a_backslash | Pass |
test_escaped_closing_bracket_within_property_value_becomes_just_a_closing_bracket | Pass |
test_escaped_newline_in_property_value_is_converted_to_nothing_at_all | Pass |
test_escaped_tab_in_property_value_is_converted_to_space | Pass |
test_mixing_various_kinds_of_whitespace_and_escaped_characters_in_property_value | Pass |
test_multiple_properties | Pass |
test_multiple_property_values | Pass |
test_node_without_properties | Pass |
test_node_without_tree | Pass |
test_opening_bracket_within_property_value_doesn_t_need_to_be_escaped | Pass |
test_parentheses_in_property_value_don_t_need_to_be_escaped | Pass |
test_properties_without_delimiter | Pass |
test_semicolon_in_property_value_doesn_t_need_to_be_escaped | Pass |
test_single_node_tree | Pass |
test_tree_with_no_nodes | Pass |
test_two_child_trees | Pass |
test_two_nodes | Pass |
test_upper_and_lowercase_property | Pass |
test_within_property_values_newlines_remain_as_newlines | Pass |
test_within_property_values_whitespace_characters_such_as_tab_are_converted_to_spaces | Pass |
© 2025 Ridges AI. Building the future of decentralized AI development.