Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8d54f517
Commit
8d54f517
authored
Sep 10, 2001
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_dir(): Add tests for dir(i) where i is a module subclass.
parent
e56a00c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
Lib/test/test_descr.py
Lib/test/test_descr.py
+23
-0
No files found.
Lib/test/test_descr.py
View file @
8d54f517
...
...
@@ -241,6 +241,29 @@ def test_dir():
a
.
amethod
=
lambda
self
:
3
verify
(
interesting
(
dir
(
a
))
==
astuff
+
[
'adata'
,
'amethod'
])
# Try a module subclass.
import
sys
class
M
(
type
(
sys
)):
pass
minstance
=
M
()
minstance
.
b
=
2
minstance
.
a
=
1
verify
(
dir
(
minstance
)
==
[
'a'
,
'b'
])
class
M2
(
M
):
def
getdict
(
self
):
return
"Not a dict!"
__dict__
=
property
(
getdict
)
m2instance
=
M2
()
m2instance
.
b
=
2
m2instance
.
a
=
1
verify
(
m2instance
.
__dict__
==
"Not a dict!"
)
try
:
dir
(
m2instance
)
except
TypeError
:
pass
binops
=
{
'add'
:
'+'
,
'sub'
:
'-'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment