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
d3548c9d
Commit
d3548c9d
authored
Aug 12, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dynamics(): add tests for dynamic *instances* (which are currently
broken). Also fix an invalid reference to C (should be S).
parent
5255b693
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
Lib/test/test_descr.py
Lib/test/test_descr.py
+20
-1
No files found.
Lib/test/test_descr.py
View file @
d3548c9d
...
...
@@ -550,7 +550,7 @@ def dynamics():
verify
(
S1
.
__dynamic__
==
0
)
class
S
(
object
):
pass
verify
(
C
.
__dynamic__
==
0
)
verify
(
S
.
__dynamic__
==
0
)
class
D
(
object
):
__dynamic__
=
1
verify
(
D
.
__dynamic__
==
1
)
...
...
@@ -581,6 +581,25 @@ def dynamics():
pass
else
:
verify
(
0
,
"assignment to SS.foo should be illegal"
)
# Test dynamic instances
class
C
(
object
):
__dynamic__
=
1
foobar
=
1
def
__repr__
(
self
):
return
"<C object>"
a
=
C
()
verify
(
not
hasattr
(
a
,
"spam"
))
verify
(
a
.
foobar
==
1
)
C
.
foobar
=
2
verify
(
a
.
foobar
==
2
)
C
.
method
=
lambda
self
:
42
verify
(
a
.
method
()
==
42
)
verify
(
repr
(
a
)
==
"<C object>"
)
C
.
__repr__
=
lambda
self
:
"C()"
verify
(
repr
(
a
)
==
"C()"
)
# The following test should succeed, but doesn't yet
## C.__int__ = lambda self: 100
## verify(int(a) == 100)
def
errors
():
if
verbose
:
print
"Testing errors..."
...
...
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