mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
gh-114552: Update __dir__
method docs: it allows returning an iterable (#114662)
This commit is contained in:
parent
b2d9d134dc
commit
e19103a346
2 changed files with 11 additions and 3 deletions
|
@ -611,6 +611,14 @@ class BuiltinTest(unittest.TestCase):
|
|||
self.assertIsInstance(res, list)
|
||||
self.assertTrue(res == ["a", "b", "c"])
|
||||
|
||||
# dir(obj__dir__iterable)
|
||||
class Foo(object):
|
||||
def __dir__(self):
|
||||
return {"b", "c", "a"}
|
||||
res = dir(Foo())
|
||||
self.assertIsInstance(res, list)
|
||||
self.assertEqual(sorted(res), ["a", "b", "c"])
|
||||
|
||||
# dir(obj__dir__not_sequence)
|
||||
class Foo(object):
|
||||
def __dir__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue