@@ -29,7 +29,7 @@ def test_reset():
29
29
assert len (basic_quotation_mark_resolver ._issues ) == 0
30
30
31
31
32
- def test_simple_quotation_mark_resolution ():
32
+ def test_simple_quotation_mark_resolution_with_no_previous_mark ():
33
33
english_quote_convention = STANDARD_QUOTE_CONVENTIONS .get_quote_convention_by_name ("standard_english" )
34
34
assert english_quote_convention is not None
35
35
@@ -40,17 +40,75 @@ def test_simple_quotation_mark_resolution():
40
40
actual_resolved_quotation_marks = list (
41
41
basic_quotation_mark_resolver .resolve_quotation_marks (
42
42
[
43
- QuotationMarkStringMatch (TextSegment .Builder ().set_text ('"test text"' ).build (), 0 , 1 ),
44
- QuotationMarkStringMatch (TextSegment .Builder ().set_text ('"test text"' ).build (), 10 , 11 ),
43
+ QuotationMarkStringMatch (TextSegment .Builder ().set_text ('test " text' ).build (), 5 , 6 ),
45
44
]
46
45
)
47
46
)
48
47
expected_resolved_quotation_marks = [
49
48
QuotationMarkMetadata (
50
- '"' , 1 , QuotationMarkDirection .OPENING , TextSegment .Builder ().set_text ('"test text"' ).build (), 0 , 1
49
+ '"' , 1 , QuotationMarkDirection .OPENING , TextSegment .Builder ().set_text ('test " text' ).build (), 5 , 6
50
+ ),
51
+ ]
52
+
53
+ assert_resolved_quotation_marks_equal (
54
+ actual_resolved_quotation_marks ,
55
+ expected_resolved_quotation_marks ,
56
+ )
57
+
58
+
59
+ def test_simple_quotation_mark_resolution_with_previous_opening_mark ():
60
+ english_quote_convention = STANDARD_QUOTE_CONVENTIONS .get_quote_convention_by_name ("standard_english" )
61
+ assert english_quote_convention is not None
62
+
63
+ basic_quotation_mark_resolver = FallbackQuotationMarkResolver (
64
+ QuotationMarkUpdateResolutionSettings (english_quote_convention .normalize ())
65
+ )
66
+
67
+ actual_resolved_quotation_marks = list (
68
+ basic_quotation_mark_resolver .resolve_quotation_marks (
69
+ [
70
+ QuotationMarkStringMatch (TextSegment .Builder ().set_text ('"test " text' ).build (), 0 , 1 ),
71
+ QuotationMarkStringMatch (TextSegment .Builder ().set_text ('"test " text' ).build (), 6 , 7 ),
72
+ ]
73
+ )
74
+ )
75
+ expected_resolved_quotation_marks = [
76
+ QuotationMarkMetadata (
77
+ '"' , 1 , QuotationMarkDirection .OPENING , TextSegment .Builder ().set_text ('"test " text' ).build (), 0 , 1
78
+ ),
79
+ QuotationMarkMetadata (
80
+ '"' , 1 , QuotationMarkDirection .CLOSING , TextSegment .Builder ().set_text ('"test " text' ).build (), 6 , 7
81
+ ),
82
+ ]
83
+
84
+ assert_resolved_quotation_marks_equal (
85
+ actual_resolved_quotation_marks ,
86
+ expected_resolved_quotation_marks ,
87
+ )
88
+
89
+
90
+ def test_simple_quotation_mark_resolution_with_previous_closing_mark ():
91
+ english_quote_convention = STANDARD_QUOTE_CONVENTIONS .get_quote_convention_by_name ("standard_english" )
92
+ assert english_quote_convention is not None
93
+
94
+ basic_quotation_mark_resolver = FallbackQuotationMarkResolver (
95
+ QuotationMarkUpdateResolutionSettings (english_quote_convention .normalize ())
96
+ )
97
+
98
+ actual_resolved_quotation_marks = list (
99
+ basic_quotation_mark_resolver .resolve_quotation_marks (
100
+ [
101
+ QuotationMarkStringMatch (TextSegment .Builder ().set_text ('test" " text' ).build (), 4 , 5 ),
102
+ QuotationMarkStringMatch (TextSegment .Builder ().set_text ('test" " text' ).build (), 6 , 7 ),
103
+ ]
104
+ )
105
+ )
106
+ expected_resolved_quotation_marks = [
107
+ QuotationMarkMetadata (
108
+ '"' , 1 , QuotationMarkDirection .CLOSING , TextSegment .Builder ().set_text ('test" " text' ).build (), 4 , 5
51
109
),
52
110
QuotationMarkMetadata (
53
- '"' , 1 , QuotationMarkDirection .CLOSING , TextSegment .Builder ().set_text ('" test text" ' ).build (), 10 , 11
111
+ '"' , 1 , QuotationMarkDirection .OPENING , TextSegment .Builder ().set_text ('test" " text ' ).build (), 6 , 7
54
112
),
55
113
]
56
114
0 commit comments