Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 847ed4a

Browse files
committed
More tweaks; re.py is nearly there...
1 parent 5310975 commit 847ed4a

3 files changed

Lines changed: 5 additions & 13 deletions

File tree

Lib/test/output/test_re

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ test_re
3434
('a[b-d]e', 'ace', 0, 'found', 'ace')
3535
('a[b-d]', 'aac', 0, 'found', 'ac')
3636
('a[-b]', 'a-', 0, 'found', 'a-')
37-
=== Syntax error: ('a[-b]', 'a-', 0, 'found', 'a-')
3837
('a[b-]', 'a-', 2)
3938
('a[]b', '-', 2)
4039
('a[', '-', 2)
@@ -43,16 +42,12 @@ test_re
4342
('(abc', '-', 2)
4443
('a]', 'a]', 0, 'found', 'a]')
4544
('a[]]b', 'a]b', 0, 'found', 'a]b')
46-
=== Syntax error: ('a[]]b', 'a]b', 0, 'found', 'a]b')
4745
('a[^bc]d', 'aed', 0, 'found', 'aed')
4846
('a[^bc]d', 'abd', 1)
4947
('a[^-b]c', 'adc', 0, 'found', 'adc')
50-
=== Syntax error: ('a[^-b]c', 'adc', 0, 'found', 'adc')
5148
('a[^-b]c', 'a-c', 1)
52-
=== Syntax error: ('a[^-b]c', 'a-c', 1)
5349
('a[^]b]c', 'a]c', 1)
5450
('a[^]b]c', 'adc', 0, 'found', 'adc')
55-
=== Failed incorrectly ('a[^]b]c', 'adc', 0, 'found', 'adc')
5651
('\\ba\\b', 'a-', 0, '"-"', '-')
5752
('\\ba\\b', '-a', 0, '"-"', '-')
5853
('\\ba\\b', '-a-', 0, '"-"', '-')
@@ -64,8 +59,7 @@ test_re
6459
('()ef', 'def', 0, 'found+"-"+g1', 'ef-')
6560
=== Syntax error: ('()ef', 'def', 0, 'found+"-"+g1', 'ef-')
6661
('$b', 'b', 1)
67-
('a(b', 'a(b', 0, 'found+"-"+g1', 'a(b-None')
68-
=== Syntax error: ('a(b', 'a(b', 0, 'found+"-"+g1', 'a(b-None')
62+
('a\\(b', 'a(b', 0, 'found+"-"+g1', 'a(b-None')
6963
('a\\(*b', 'ab', 0, 'found', 'ab')
7064
('a\\(*b', 'a((b', 0, 'found', 'a((b')
7165
('a\\\\b', 'a\\b', 0, 'found', 'a\\b')
@@ -113,7 +107,6 @@ test_re
113107
('\\((.*), (.*)\\)', '(a, b)', 0, 'g2+"-"+g1', 'b-a')
114108
('[k]', 'ab', 1)
115109
('a[-]?c', 'ac', 0, 'found', 'ac')
116-
=== Syntax error: ('a[-]?c', 'ac', 0, 'found', 'ac')
117110
('(abc)\\1', 'abcabc', 0, 'g1', 'abc')
118111
('([a-c]*)\\1', 'abcabc', 0, 'g1', 'abc')
119112
('^(.+)?B', 'AB', 0, 'g1', 'A')

Lib/test/re_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
('()ef', 'def', SUCCEED,
137137
'found+"-"+g1', 'ef-'),
138138
('$b', 'b', FAIL),
139-
('a(b', 'a(b', SUCCEED,
139+
('a\\(b', 'a(b', SUCCEED,
140140
'found+"-"+g1', 'a(b-None'),
141141
('a\\(*b', 'ab', SUCCEED,
142142
'found', 'ab'),

Lib/test/test_re.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,15 @@
4141
# Matched, as expected, so now we compute the
4242
# result string and compare it to our expected result.
4343
start, end = result.span(0)
44-
vardict={'found': result.group(0)}
44+
vardict={'found': result.group(0), 'groups': result.group()}
4545
for i in range(1, 100):
4646
try:
4747
gi = result.group(i)
4848
# Special hack because else the string concat fails:
4949
if gi is None: gi = "None"
5050
except IndexError:
51-
break
52-
else:
53-
vardict['g%d' % i] = gi
51+
gi = "None"
52+
vardict['g%d' % i] = gi
5453
repl=eval(repl, vardict)
5554
if repl!=expected:
5655
print '=== grouping error', t,

0 commit comments

Comments
 (0)