Skip to content
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Lib/test/test_funcattrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import typing
import unittest
import warnings
from test import support


def global_function():
Expand Down Expand Up @@ -478,6 +479,27 @@ def test_builtin__qualname__(self):
self.assertEqual([1, 2, 3].append.__qualname__, 'list.append')
self.assertEqual({'foo': 'bar'}.pop.__qualname__, 'dict.pop')

@support.cpython_only # See gh-58211
def test_builtin__self__(self):
Comment thread
adorilson marked this conversation as resolved.
Outdated
import time
import builtins
Comment thread
adorilson marked this conversation as resolved.
Outdated

# builtin function:
self.assertEqual(len.__self__, builtins)
Comment thread
serhiy-storchaka marked this conversation as resolved.
Outdated
self.assertEqual(time.sleep.__self__, time)

# builtin classmethod:
self.assertEqual(dict.fromkeys.__self__, dict)
self.assertEqual(float.__getformat__.__self__, float)

# builtin staticmethod:
self.assertEqual(str.maketrans.__self__, None)
Comment thread
serhiy-storchaka marked this conversation as resolved.
Outdated
self.assertEqual(bytes.maketrans.__self__, None)

# builtin bound instance method:
self.assertEqual([1, 2, 3].append.__self__, [1, 2, 3])
Comment thread
serhiy-storchaka marked this conversation as resolved.
Outdated
self.assertEqual({'foo': 'bar'}.pop.__self__, {'foo': 'bar'})

Comment thread
serhiy-storchaka marked this conversation as resolved.

if __name__ == "__main__":
unittest.main()
Loading