-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-136535: Tests: Correct Py_TPFLAGS_MANAGED_DICT
in test_class.py
#136538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
407de3c
9cd9c5b
b39ca1a
fd8e8e6
63aff56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -859,7 +859,12 @@ def __init__(self, arg): | |||||||
|
||||||||
from _testinternalcapi import has_inline_values | ||||||||
|
||||||||
Py_TPFLAGS_MANAGED_DICT = (1 << 2) | ||||||||
Py_TPFLAGS_INLINE_VALUES = (1 << 2) | ||||||||
Py_TPFLAGS_MANAGED_DICT = (1 << 4) | ||||||||
|
||||||||
class NoManagedDict: | ||||||||
__slots__ = ('a',) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
pep 8 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||
|
||||||||
|
||||||||
class Plain: | ||||||||
pass | ||||||||
|
@@ -874,11 +879,31 @@ def __init__(self): | |||||||
self.d = 4 | ||||||||
|
||||||||
|
||||||||
class VarSizedSubclass(tuple): | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
pass | ||||||||
|
||||||||
|
||||||||
class TestInlineValues(unittest.TestCase): | ||||||||
|
||||||||
def test_flags(self): | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revive test_flags also. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ever0de Oh it was my miss, you don't have to revive :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see, Should I drop this commit then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, please revert b39ca1a |
||||||||
self.assertEqual(Plain.__flags__ & Py_TPFLAGS_MANAGED_DICT, Py_TPFLAGS_MANAGED_DICT) | ||||||||
self.assertEqual(WithAttrs.__flags__ & Py_TPFLAGS_MANAGED_DICT, Py_TPFLAGS_MANAGED_DICT) | ||||||||
def test_no_flags_for_slots_class(self): | ||||||||
flags = NoManagedDict.__flags__ | ||||||||
self.assertEqual(flags & Py_TPFLAGS_MANAGED_DICT, 0) | ||||||||
self.assertEqual(flags & Py_TPFLAGS_INLINE_VALUES, 0) | ||||||||
self.assertFalse(has_inline_values(NoManagedDict())) | ||||||||
|
||||||||
def test_both_flags_for_regular_class(self): | ||||||||
for cls in (Plain, WithAttrs): | ||||||||
with self.subTest(cls=cls.__name__): | ||||||||
flags = cls.__flags__ | ||||||||
self.assertEqual(flags & Py_TPFLAGS_MANAGED_DICT, Py_TPFLAGS_MANAGED_DICT) | ||||||||
self.assertEqual(flags & Py_TPFLAGS_INLINE_VALUES, Py_TPFLAGS_INLINE_VALUES) | ||||||||
self.assertTrue(has_inline_values(cls())) | ||||||||
|
||||||||
def test_managed_dict_only_for_varsized_subclass(self): | ||||||||
flags = VarSizedSubclass.__flags__ | ||||||||
self.assertEqual(flags & Py_TPFLAGS_MANAGED_DICT, Py_TPFLAGS_MANAGED_DICT) | ||||||||
self.assertEqual(flags & Py_TPFLAGS_INLINE_VALUES, 0) | ||||||||
self.assertFalse(has_inline_values(VarSizedSubclass())) | ||||||||
|
||||||||
def test_has_inline_values(self): | ||||||||
c = Plain() | ||||||||
|
Uh oh!
There was an error while loading. Please reload this page.