diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2024-02-10 08:34:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-10 08:34:23 (GMT) |
commit | e19103a346f0277c44a43dfaebad9a5aa468bf1e (patch) | |
tree | be8b2171da023bf9f748a64be22e45a008fe8ec0 /Lib | |
parent | b2d9d134dcb5633deebebf2b0118cd4f7ca598a2 (diff) | |
download | cpython-e19103a346f0277c44a43dfaebad9a5aa468bf1e.zip cpython-e19103a346f0277c44a43dfaebad9a5aa468bf1e.tar.gz cpython-e19103a346f0277c44a43dfaebad9a5aa468bf1e.tar.bz2 |
gh-114552: Update `__dir__` method docs: it allows returning an iterable (#114662)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_builtin.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index fcddd14..7a3ab22 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -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): |