Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8ae9ce5e
Commit
8ae9ce5e
authored
Aug 18, 2000
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better conformance to the Python Style Guide: use spaces around operators.
parent
fe5c22a8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
32 deletions
+33
-32
Lib/test/test_re.py
Lib/test/test_re.py
+33
-32
No files found.
Lib/test/test_re.py
View file @
8ae9ce5e
import
sys
sys
.
path
=
[
'.'
]
+
sys
.
path
sys
.
path
=
[
'.'
]
+
sys
.
path
from
test_support
import
verbose
,
TestFailed
import
re
...
...
@@ -270,18 +270,18 @@ else:
for t in tests:
sys.stdout.flush()
pattern
=s=outcome=repl=expected=
None
if len(t)
==
5:
pattern
= s = outcome = repl = expected =
None
if len(t)
==
5:
pattern, s, outcome, repl, expected = t
elif len(t)
==
3:
elif len(t)
==
3:
pattern, s, outcome = t
else:
raise ValueError, ('
Test
tuples
should
have
3
or
5
fields
',t)
raise ValueError, ('
Test
tuples
should
have
3
or
5
fields
',
t)
try:
obj
=
re.compile(pattern)
obj
=
re.compile(pattern)
except re.error:
if outcome
==
SYNTAX_ERROR: pass # Expected a syntax error
if outcome
==
SYNTAX_ERROR: pass # Expected a syntax error
else:
print '
===
Syntax
error
:
', t
except KeyboardInterrupt: raise KeyboardInterrupt
...
...
@@ -291,16 +291,16 @@ for t in tests:
traceback.print_exc(file=sys.stdout)
else:
try:
result
=
obj.search(s)
except
(re.error)
, msg:
result
=
obj.search(s)
except
re.error
, msg:
print '
===
Unexpected
exception
', t, repr(msg)
if outcome
==
SYNTAX_ERROR:
if outcome
==
SYNTAX_ERROR:
# This should have been a syntax error; forget it.
pass
elif outcome
==
FAIL:
elif outcome
==
FAIL:
if result is None: pass # No match, as expected
else: print '
===
Succeeded
incorrectly
', t
elif outcome
==
SUCCEED:
elif outcome
==
SUCCEED:
if result is not None:
# Matched, as expected, so now we compute the
# result string and compare it to our expected result.
...
...
@@ -325,24 +325,24 @@ for t in tests:
except IndexError:
gi = "Error"
vardict[i] = gi
repl
=
eval(repl, vardict)
if repl
!=
expected:
repl
=
eval(repl, vardict)
if repl
!=
expected:
print '
===
grouping
error
', t,
print repr(repl)
+'
should
be
'+
repr(expected)
print repr(repl)
+ '
should
be
' +
repr(expected)
else:
print '
===
Failed
incorrectly
', t
# Try the match on a unicode string, and check that it
# still succeeds.
result
=
obj.search(unicode(s, "latin-1"))
if result
==
None:
result
=
obj.search(unicode(s, "latin-1"))
if result
==
None:
print '
===
Fails
on
unicode
match
', t
# Try the match on a unicode pattern, and check that it
# still succeeds.
obj=re.compile(unicode(pattern, "latin-1"))
result
=
obj.search(s)
if result
==
None:
result
=
obj.search(s)
if result
==
None:
print '
===
Fails
on
unicode
pattern
match
', t
# Try the match with the search area limited to the extent
...
...
@@ -350,29 +350,30 @@ for t in tests:
# break (because it won'
t
match
at
the
end
or
start
of
a
# string), so we'll ignore patterns that feature it.
if
pattern
[:
2
]
!=
'
\
\
B'
and
pattern
[
-
2
:]
!=
'
\
\
B'
and
result
!=
None
:
obj
=
re
.
compile
(
pattern
)
result
=
obj
.
search
(
s
,
result
.
start
(
0
),
result
.
end
(
0
)
+
1
)
if
result
==
None
:
if
pattern
[:
2
]
!=
'
\
\
B'
and
pattern
[
-
2
:]
!=
'
\
\
B'
\
and
result
!=
None
:
obj
=
re
.
compile
(
pattern
)
result
=
obj
.
search
(
s
,
result
.
start
(
0
),
result
.
end
(
0
)
+
1
)
if
result
==
None
:
print
'=== Failed on range-limited match'
,
t
# Try the match with IGNORECASE enabled, and check that it
# still succeeds.
obj
=
re
.
compile
(
pattern
,
re
.
IGNORECASE
)
result
=
obj
.
search
(
s
)
if
result
==
None
:
obj
=
re
.
compile
(
pattern
,
re
.
IGNORECASE
)
result
=
obj
.
search
(
s
)
if
result
==
None
:
print
'=== Fails on case-insensitive match'
,
t
# Try the match with LOCALE enabled, and check that it
# still succeeds.
obj
=
re
.
compile
(
pattern
,
re
.
LOCALE
)
result
=
obj
.
search
(
s
)
if
result
==
None
:
obj
=
re
.
compile
(
pattern
,
re
.
LOCALE
)
result
=
obj
.
search
(
s
)
if
result
==
None
:
print
'=== Fails on locale-sensitive match'
,
t
# Try the match with UNICODE locale enabled, and check
# that it still succeeds.
obj
=
re
.
compile
(
pattern
,
re
.
UNICODE
)
result
=
obj
.
search
(
s
)
if
result
==
None
:
obj
=
re
.
compile
(
pattern
,
re
.
UNICODE
)
result
=
obj
.
search
(
s
)
if
result
==
None
:
print
'=== Fails on unicode-sensitive match'
,
t
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment