mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
[3.13] gh-60712: Include the "object" type in the lists of documented types (GH-103036) (GH-126197)
gh-60712: Include the "object" type in the lists of documented types (GH-103036)
* add test for the predefined object's attributes
* Include the "object" type in the lists of documented types
* remove 'or' from augment tuple
* 📜🤖 Added by blurb_it.
* Add cross-reference to news
* Fix format for the function parameter
* Add space
* add reference for the 'object'
* add reference for NotImplemented
* Change ref:`string <textseq>` as class:`str`
* remove hyphen from `newly-created`
* Update Doc/reference/datamodel.rst
'dictionaries' to 'dict'
* Update predefined attribute types in testPredefinedAttrs
* Change `universal type` as `top type`
* Don't mention about the top type
* Update the description of richcmpfuncs
* Update Doc/library/stdtypes.rst
* Revert: Hierarchy Section in Data Model Documentation
* Revert to original explanations of __new__ and __init__ methods in datamodel.rst for improved clarity.
* Update Doc/reference/datamodel.rst
* Remove blank line
* Use ref:`str <textseq>` instead of :class:`str
* Revert changes the description of Other Built-in Types in stdtypes.rst
* Update Doc/reference/datamodel.rst
---------
(cherry picked from commit 4f826214b3
)
Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
This commit is contained in:
parent
e6e140db9e
commit
00ff23f06d
4 changed files with 93 additions and 18 deletions
|
@ -503,6 +503,56 @@ class ClassTests(unittest.TestCase):
|
|||
|
||||
self.assertRaises(TypeError, hash, C2())
|
||||
|
||||
def testPredefinedAttrs(self):
|
||||
o = object()
|
||||
|
||||
class Custom:
|
||||
pass
|
||||
|
||||
c = Custom()
|
||||
|
||||
methods = (
|
||||
'__class__', '__delattr__', '__dir__', '__eq__', '__format__',
|
||||
'__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__',
|
||||
'__init__', '__init_subclass__', '__le__', '__lt__', '__ne__',
|
||||
'__new__', '__reduce__', '__reduce_ex__', '__repr__',
|
||||
'__setattr__', '__sizeof__', '__str__', '__subclasshook__'
|
||||
)
|
||||
for name in methods:
|
||||
with self.subTest(name):
|
||||
self.assertTrue(callable(getattr(object, name, None)))
|
||||
self.assertTrue(callable(getattr(o, name, None)))
|
||||
self.assertTrue(callable(getattr(Custom, name, None)))
|
||||
self.assertTrue(callable(getattr(c, name, None)))
|
||||
|
||||
not_defined = [
|
||||
'__abs__', '__aenter__', '__aexit__', '__aiter__', '__anext__',
|
||||
'__await__', '__bool__', '__bytes__', '__ceil__',
|
||||
'__complex__', '__contains__', '__del__', '__delete__',
|
||||
'__delitem__', '__divmod__', '__enter__', '__exit__',
|
||||
'__float__', '__floor__', '__get__', '__getattr__', '__getitem__',
|
||||
'__index__', '__int__', '__invert__', '__iter__', '__len__',
|
||||
'__length_hint__', '__missing__', '__neg__', '__next__',
|
||||
'__objclass__', '__pos__', '__rdivmod__', '__reversed__',
|
||||
'__round__', '__set__', '__setitem__', '__trunc__'
|
||||
]
|
||||
augment = (
|
||||
'add', 'and', 'floordiv', 'lshift', 'matmul', 'mod', 'mul', 'pow',
|
||||
'rshift', 'sub', 'truediv', 'xor'
|
||||
)
|
||||
not_defined.extend(map("__{}__".format, augment))
|
||||
not_defined.extend(map("__r{}__".format, augment))
|
||||
not_defined.extend(map("__i{}__".format, augment))
|
||||
for name in not_defined:
|
||||
with self.subTest(name):
|
||||
self.assertFalse(hasattr(object, name))
|
||||
self.assertFalse(hasattr(o, name))
|
||||
self.assertFalse(hasattr(Custom, name))
|
||||
self.assertFalse(hasattr(c, name))
|
||||
|
||||
# __call__() is defined on the metaclass but not the class
|
||||
self.assertFalse(hasattr(o, "__call__"))
|
||||
self.assertFalse(hasattr(c, "__call__"))
|
||||
|
||||
def testSFBug532646(self):
|
||||
# Test for SF bug 532646
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue