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
35b9ff36
Commit
35b9ff36
authored
Apr 25, 2003
by
Skip Montanaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deleted more tests which were either already in test_re or that I migrated
in the last revison
parent
1e703c62
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
76 deletions
+0
-76
Lib/test/test_sre.py
Lib/test/test_sre.py
+0
-76
No files found.
Lib/test/test_sre.py
View file @
35b9ff36
...
...
@@ -114,79 +114,3 @@ test(r"""pat.match('ac').group(1, 'b2', 3)""", ('a', None, 'c'))
for
op
in
''
,
'?'
,
'*'
:
test
(
r"""sre.match(r'((.%s):)?z', 'z').groups()"""
%
op
,
(
None
,
None
))
test
(
r"""sre.match(r'((.%s):)?z', 'a:z').groups()"""
%
op
,
(
'a:'
,
'a'
))
if
verbose
:
print
"Running tests on sre.escape"
p
=
""
for
i
in
range
(
0
,
256
):
p
=
p
+
chr
(
i
)
test
(
r"""sre.match(sre.escape(chr(i)), chr(i)) is not None"""
,
1
)
test
(
r"""sre.match(sre.escape(chr(i)), chr(i)).span()"""
,
(
0
,
1
))
pat
=
sre
.
compile
(
sre
.
escape
(
p
))
test
(
r"""pat.match(p) is not None"""
,
1
)
test
(
r"""pat.match(p).span()"""
,
(
0
,
256
))
if
verbose
:
print
'Running tests on sre.Scanner'
def
s_ident
(
scanner
,
token
):
return
token
def
s_operator
(
scanner
,
token
):
return
"op%s"
%
token
def
s_float
(
scanner
,
token
):
return
float
(
token
)
def
s_int
(
scanner
,
token
):
return
int
(
token
)
scanner
=
sre
.
Scanner
([
(
r"[a-zA-Z_]\
w*
", s_ident),
(r"
\
d
+
\
.
\
d
*
", s_float),
(r"
\
d
+
", s_int),
(r"
=|
\
+|-|
\
*|/
", s_operator),
(r"
\
s
+
", None),
])
# sanity check
test('scanner.scan("
sum
=
3
*
foo
+
312.50
+
bar
")',
(['sum', 'op=', 3, 'op*', 'foo', 'op+', 312.5, 'op+', 'bar'], ''))
if verbose:
print 'Pickling a SRE_Pattern instance'
try:
import pickle
pat = sre.compile(r'a(?:b|(c|e){1,2}?|d)+?(.)')
s = pickle.dumps(pat)
pat = pickle.loads(s)
except:
print TestFailed, 're module pickle'
try:
import cPickle
pat = sre.compile(r'a(?:b|(c|e){1,2}?|d)+?(.)')
s = cPickle.dumps(pat)
pat = cPickle.loads(s)
except:
print TestFailed, 're module cPickle'
# constants
test(r"""sre.I""", sre.IGNORECASE)
test(r"""sre.L""", sre.LOCALE)
test(r"""sre.M""", sre.MULTILINE)
test(r"""sre.S""", sre.DOTALL)
test(r"""sre.X""", sre.VERBOSE)
test(r"""sre.T""", sre.TEMPLATE)
test(r"""sre.U""", sre.UNICODE)
for flags in [sre.I, sre.M, sre.X, sre.S, sre.L, sre.T, sre.U]:
try:
r = sre.compile('^pattern$', flags)
except:
print 'Exception raised on flag', flags
if verbose:
print 'Test engine limitations'
# Try nasty case that overflows the straightforward recursive
# implementation of repeated groups.
test("
sre
.
match
(
'(x)*'
,
50000
*
'x'
).
span
()
", (0, 50000), RuntimeError)
test("
sre
.
match
(
r'(x)*y'
,
50000
*
'x'
+
'y'
).
span
()
", (0, 50001), RuntimeError)
test("
sre
.
match
(
r'(x)*?y'
,
50000
*
'x'
+
'y'
).
span
()
", (0, 50001), RuntimeError)
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