Author: Brian Kearns <[email protected]>
Branch: stdlib-2.7.6
Changeset: r69628:312589f4d6e7
Date: 2014-03-02 21:18 -0500
http://bitbucket.org/pypy/pypy/changeset/312589f4d6e7/
Log: cleanup
diff --git a/pypy/module/_sre/test/support_test_app_sre.py
b/pypy/module/_sre/test/support_test_app_sre.py
--- a/pypy/module/_sre/test/support_test_app_sre.py
+++ b/pypy/module/_sre/test/support_test_app_sre.py
@@ -1,6 +1,6 @@
"""Support functions for app-level _sre tests."""
import locale, _sre
-from sre_constants import OPCODES, ATCODES, CHCODES
+from sre_constants import OPCODES, ATCODES, CHCODES, MAXREPEAT
def encode_literal(string):
opcodes = []
diff --git a/pypy/module/_sre/test/test_app_sre.py
b/pypy/module/_sre/test/test_app_sre.py
--- a/pypy/module/_sre/test/test_app_sre.py
+++ b/pypy/module/_sre/test/test_app_sre.py
@@ -1,12 +1,15 @@
"""Regular expression tests specific to _sre.py and accumulated during TDD."""
+
import os
import py
from py.test import raises, skip
from pypy.interpreter.gateway import app2interp_temp
+
def init_app_test(cls, space):
- cls.w_s =
space.appexec([space.wrap(os.path.realpath(os.path.dirname(__file__)))],
- """(this_dir):
+ cls.w_s = space.appexec(
+ [space.wrap(os.path.realpath(os.path.dirname(__file__)))],
+ """(this_dir):
import sys
# Uh-oh, ugly hack
sys.path.insert(0, this_dir)
@@ -15,11 +18,10 @@
return support_test_app_sre
finally:
sys.path.pop(0)
- """)
+ """)
class AppTestSrePy:
-
def test_magic(self):
import _sre, sre_constants
assert sre_constants.MAGIC == _sre.MAGIC
@@ -30,7 +32,6 @@
class AppTestSrePattern:
-
def test_copy(self):
# copy support is disabled by default in _sre.c
import re
@@ -94,7 +95,7 @@
class AppTestSreMatch:
spaceconfig = dict(usemodules=('array', ))
-
+
def test_copy(self):
import re
# copy support is disabled by default in _sre.c
@@ -242,6 +243,10 @@
assert u2 == u1
assert type(u2) is unicode # and not MyUnicode
+ def test_sub_bug(self):
+ import re
+ assert re.sub('=\w{2}', 'x', '=CA') == 'x'
+
def test_match_array(self):
import re, array
a = array.array('c', 'hello')
@@ -294,7 +299,6 @@
class AppTestSreScanner:
-
def test_scanner_attributes(self):
import re
p = re.compile("bla")
@@ -346,7 +350,7 @@
def setup_method(self, method):
import locale
locale.setlocale(locale.LC_ALL, (None, None))
-
+
def teardown_method(self, method):
import locale
locale.setlocale(locale.LC_ALL, (None, None))
@@ -382,10 +386,9 @@
s.assert_lower_equal([("a", "a"), ("A", "a"), (UPPER_AE, LOWER_AE),
(u"\u00c4", u"\u00e4"), (UPPER_PI, LOWER_PI),
(u"\u4444", u"\u4444")], sre_constants.SRE_FLAG_UNICODE)
-
+
class AppTestSimpleSearches:
-
def test_search_simple_literal(self):
import re
assert re.search("bla", "bla")
@@ -556,16 +559,8 @@
assert re.search(r"b(?<!\d.)a", "ba")
assert not re.search(r"b(?<!\d.)a", "11ba")
- def test_bug_725149(self):
- # mark_stack_base restoring before restoring marks
- # test copied from CPython test
- import re
- assert re.match('(a)(?:(?=(b)*)c)*', 'abb').groups() == ('a', None)
- assert re.match('(a)((?!(b)*))*', 'abb').groups() == ('a', None, None)
-
class AppTestMarksStack:
-
def test_mark_stack_branch(self):
import re
m = re.match("b(.)a|b.b", "bob")
@@ -595,7 +590,14 @@
m = re.match("(\d)+?1((2)|(3))44", "221341244")
assert ("2", "2", None) == m.group(2, 3, 4)
assert 2 == m.lastindex
-
+
+ def test_bug_725149(self):
+ # mark_stack_base restoring before restoring marks
+ # test copied from CPython test
+ import re
+ assert re.match('(a)(?:(?=(b)*)c)*', 'abb').groups() == ('a', None)
+ assert re.match('(a)((?!(b)*))*', 'abb').groups() == ('a', None, None)
+
class AppTestOpcodes:
spaceconfig = dict(usemodules=('_locale',))
@@ -875,21 +877,21 @@
def test_repeat_one(self):
s = self.s
- opcodes = [s.OPCODES["repeat_one"], 6, 1, 65535] +
s.encode_literal("a") \
+ opcodes = [s.OPCODES["repeat_one"], 6, 1, self.s.MAXREPEAT] +
s.encode_literal("a") \
+ [s.OPCODES["success"]] + s.encode_literal("ab") +
[s.OPCODES["success"]]
s.assert_match(opcodes, ["aab", "aaaab"])
s.assert_no_match(opcodes, ["ab", "a"])
def test_min_repeat_one(self):
s = self.s
- opcodes = [s.OPCODES["min_repeat_one"], 5, 1, 65535, s.OPCODES["any"]]
\
+ opcodes = [s.OPCODES["min_repeat_one"], 5, 1, self.s.MAXREPEAT,
s.OPCODES["any"]] \
+ [s.OPCODES["success"]] + s.encode_literal("b") +
[s.OPCODES["success"]]
s.assert_match(opcodes, ["aab", "ardb", "bb"])
s.assert_no_match(opcodes, ["b"])
def test_repeat_maximizing(self):
s = self.s
- opcodes = [s.OPCODES["repeat"], 5, 1, 65535] + s.encode_literal("a") \
+ opcodes = [s.OPCODES["repeat"], 5, 1, self.s.MAXREPEAT] +
s.encode_literal("a") \
+ [s.OPCODES["max_until"]] + s.encode_literal("b") +
[s.OPCODES["success"]]
s.assert_match(opcodes, ["ab", "aaaab", "baabb"])
s.assert_no_match(opcodes, ["aaa", "", "ac"])
@@ -901,15 +903,15 @@
import sys
if not sys.version_info[:2] == (2, 3):
s = self.s
- opcodes = [s.OPCODES["repeat"], 10, 1, 65535,
s.OPCODES["repeat_one"],
- 6, 0, 65535] + s.encode_literal("a") + [s.OPCODES["success"],
+ opcodes = [s.OPCODES["repeat"], 10, 1, self.s.MAXREPEAT,
s.OPCODES["repeat_one"],
+ 6, 0, self.s.MAXREPEAT] + s.encode_literal("a") +
[s.OPCODES["success"],
s.OPCODES["max_until"], s.OPCODES["success"]]
s.assert_match(opcodes, ["ab", "bb"])
assert "" == s.search(opcodes, "bb").group(0)
def test_repeat_minimizing(self):
s = self.s
- opcodes = [s.OPCODES["repeat"], 4, 1, 65535, s.OPCODES["any"],
+ opcodes = [s.OPCODES["repeat"], 4, 1, self.s.MAXREPEAT,
s.OPCODES["any"],
s.OPCODES["min_until"]] + s.encode_literal("b") +
[s.OPCODES["success"]]
s.assert_match(opcodes, ["ab", "aaaab", "baabb"])
s.assert_no_match(opcodes, ["b"])
@@ -944,9 +946,6 @@
s.assert_match(opcodes, ["a"])
s.assert_no_match(opcodes, ["ab"])
- def test_bug(self):
- import re
- assert re.sub('=\w{2}', 'x', '=CA') == 'x'
class AppTestOptimizations:
"""These tests try to trigger optmized edge cases."""
diff --git a/pypy/module/select/test/test_select.py
b/pypy/module/select/test/test_select.py
--- a/pypy/module/select/test/test_select.py
+++ b/pypy/module/select/test/test_select.py
@@ -213,15 +213,10 @@
readend.close()
writeend.close()
- def test_poll_int_arguments(self):
+ def test_poll_arguments(self):
import select
-
pollster = select.poll()
pollster.register(1)
-
- raises(OverflowError, pollster.poll, 1L << 64)
-
- pollster = select.poll()
exc = raises(OverflowError, pollster.register, 0, 32768) # SHRT_MAX + 1
assert exc.value[0] == 'signed short integer is greater than maximum'
exc = raises(OverflowError, pollster.register, 0, -32768 - 1)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit