mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
#3247 Get rid of Py_FindMethod; use tp_members instead.
Otherwise dir(_sre.SRE_Match) returns an empty list. First step: handle most occurrences, remove tp_getattr and fill the tp_methods and tp_members slots. Add some test about attribute access.
This commit is contained in:
parent
4118174315
commit
e43d33a4db
13 changed files with 388 additions and 329 deletions
|
@ -326,6 +326,13 @@ class ReTests(unittest.TestCase):
|
|||
self.assertNotEqual(re.match("^x{}$", "x{}"), None)
|
||||
|
||||
def test_getattr(self):
|
||||
self.assertEqual(re.compile("(?i)(a)(b)").pattern, "(?i)(a)(b)")
|
||||
self.assertEqual(re.compile("(?i)(a)(b)").flags, re.I)
|
||||
self.assertEqual(re.compile("(?i)(a)(b)").groups, 2)
|
||||
self.assertEqual(re.compile("(?i)(a)(b)").groupindex, {})
|
||||
self.assertEqual(re.compile("(?i)(?P<first>a)(?P<other>b)").groupindex,
|
||||
{'first': 1, 'other': 2})
|
||||
|
||||
self.assertEqual(re.match("(a)", "a").pos, 0)
|
||||
self.assertEqual(re.match("(a)", "a").endpos, 1)
|
||||
self.assertEqual(re.match("(a)", "a").string, "a")
|
||||
|
|
|
@ -29,6 +29,7 @@ class WinregTests(unittest.TestCase):
|
|||
# Set the default value for this key.
|
||||
SetValue(root_key, test_key_name, REG_SZ, "Default value")
|
||||
key = CreateKey(root_key, test_key_name)
|
||||
self.assert_(key.handle != 0)
|
||||
# Create a sub-key
|
||||
sub_key = CreateKey(key, subkeystr)
|
||||
# Give the sub-key some named values
|
||||
|
|
|
@ -161,6 +161,7 @@ class CompressObjectTestCase(unittest.TestCase):
|
|||
self.assertEqual(b'', dco.unconsumed_tail, ########
|
||||
"(A) uct should be b'': not %d long" %
|
||||
len(dco.unconsumed_tail))
|
||||
self.assertEqual(b'', dco.unused_data)
|
||||
if flush:
|
||||
bufs.append(dco.flush())
|
||||
else:
|
||||
|
@ -173,6 +174,7 @@ class CompressObjectTestCase(unittest.TestCase):
|
|||
self.assertEqual(b'', dco.unconsumed_tail, ########
|
||||
"(B) uct should be b'': not %d long" %
|
||||
len(dco.unconsumed_tail))
|
||||
self.assertEqual(b'', dco.unused_data)
|
||||
self.assertEqual(data, b''.join(bufs))
|
||||
# Failure means: "decompressobj with init options failed"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue