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
b7a7731e
Commit
b7a7731e
authored
Jul 30, 2001
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for getattr() and hasattr() with non-string args
parent
302b54ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
Lib/test/test_b1.py
Lib/test/test_b1.py
+18
-0
Lib/test/test_b2.py
Lib/test/test_b2.py
+6
-0
No files found.
Lib/test/test_b1.py
View file @
b7a7731e
...
...
@@ -256,10 +256,28 @@ if float(u" \u0663.\u0661\u0664 ") != 3.14:
print
'getattr'
import
sys
if
getattr
(
sys
,
'stdout'
)
is
not
sys
.
stdout
:
raise
TestFailed
,
'getattr'
try
:
getattr
(
sys
,
1
)
except
TypeError
:
pass
else
:
raise
TestFailed
,
"getattr(sys, 1) should raise an exception"
try
:
getattr
(
sys
,
1
,
"foo"
)
except
TypeError
:
pass
else
:
raise
TestFailed
,
'getattr(sys, 1, "foo") should raise an exception'
print
'hasattr'
import
sys
if
not
hasattr
(
sys
,
'stdout'
):
raise
TestFailed
,
'hasattr'
try
:
hasattr
(
sys
,
1
)
except
TypeError
:
pass
else
:
raise
TestFailed
,
"hasattr(sys, 1) should raise an exception"
print
'hash'
hash
(
None
)
...
...
Lib/test/test_b2.py
View file @
b7a7731e
...
...
@@ -205,6 +205,12 @@ print 'setattr'
import
sys
setattr
(
sys
,
'spam'
,
1
)
if
sys
.
spam
!=
1
:
raise
TestFailed
,
'setattr(sys,
\
'
spam
\
'
, 1)'
try
:
setattr
(
sys
,
1
,
'spam'
)
except
TypeError
:
pass
else
:
raise
TestFailed
,
"setattr(sys, 1, 'spam') should raise exception"
print
'str'
if
str
(
''
)
!=
''
:
raise
TestFailed
,
'str(
\
'
\
'
)'
...
...
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