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
8b056da6
Commit
8b056da6
authored
Aug 13, 2002
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for including __dict__ and/or __weakref__ in __slots__.
Add some more rigor to slotmultipleinheritance().
parent
b0df6a1a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
1 deletion
+50
-1
Lib/test/test_descr.py
Lib/test/test_descr.py
+50
-1
No files found.
Lib/test/test_descr.py
View file @
8b056da6
...
...
@@ -1175,6 +1175,51 @@ def slots():
new_objects
=
len
(
gc
.
get_objects
())
vereq
(
orig_objects
,
new_objects
)
def
slotspecials
():
if
verbose
:
print
"Testing __dict__ and __weakref__ in __slots__..."
class
D
(
object
):
__slots__
=
[
"__dict__"
]
a
=
D
()
verify
(
hasattr
(
a
,
"__dict__"
))
verify
(
not
hasattr
(
a
,
"__weakref__"
))
a
.
foo
=
42
vereq
(
a
.
__dict__
,
{
"foo"
:
42
})
class
W
(
object
):
__slots__
=
[
"__weakref__"
]
a
=
W
()
verify
(
hasattr
(
a
,
"__weakref__"
))
verify
(
not
hasattr
(
a
,
"__dict__"
))
try
:
a
.
foo
=
42
except
AttributeError
:
pass
else
:
raise
TestFailed
,
"shouldn't be allowed to set a.foo"
class
C1
(
W
,
D
):
__slots__
=
[]
a
=
C1
()
verify
(
hasattr
(
a
,
"__dict__"
))
verify
(
hasattr
(
a
,
"__weakref__"
))
a
.
foo
=
42
vereq
(
a
.
__dict__
,
{
"foo"
:
42
})
class
C2
(
D
,
W
):
__slots__
=
[]
a
=
C2
()
verify
(
hasattr
(
a
,
"__dict__"
))
verify
(
hasattr
(
a
,
"__weakref__"
))
a
.
foo
=
42
vereq
(
a
.
__dict__
,
{
"foo"
:
42
})
class
C3
(
C1
,
C2
):
__slots__
=
[]
class
C4
(
C2
,
C1
):
__slots__
=
[]
def
dynamics
():
if
verbose
:
print
"Testing class attribute propagation..."
class
D
(
object
):
...
...
@@ -3245,7 +3290,10 @@ def slotmultipleinheritance():
pass
class
C
(
A
,
B
)
:
__slots__
=
()
C
().
x
=
2
vereq
(
C
.
__basicsize__
,
B
.
__basicsize__
)
verify
(
hasattr
(
C
,
'__dict__'
))
verify
(
hasattr
(
C
,
'__weakref__'
))
C
().
x
=
2
def
testrmul
():
# SF patch 592646
...
...
@@ -3304,6 +3352,7 @@ def test_main():
diamond
()
objects
()
slots
()
slotspecials
()
dynamics
()
errors
()
classmethods
()
...
...
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