Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zope.proxy
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
zope.proxy
Commits
0523a7e3
Commit
0523a7e3
authored
May 07, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the new tests to try to avoid a conflict with the previous PR.
parent
934dc2fa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
65 deletions
+64
-65
src/zope/proxy/tests/test_proxy.py
src/zope/proxy/tests/test_proxy.py
+64
-65
No files found.
src/zope/proxy/tests/test_proxy.py
View file @
0523a7e3
...
...
@@ -75,6 +75,70 @@ class PyProxyBaseTestCase(unittest.TestCase):
proxy
=
MyProxy3
(
'notused'
)
self
.
assertEqual
(
list
(
proxy
),
list
(
'another'
))
def
test_string_to_int
(
self
):
# Strings don't have the tp_number.tp_int pointer
proxy
=
self
.
_makeOne
(
"14"
)
self
.
assertEqual
(
14
,
int
(
proxy
))
def
test_custom_int_to_int
(
self
):
class
CustomClass
(
object
):
def
__int__
(
self
):
return
42
proxy
=
self
.
_makeOne
(
CustomClass
())
self
.
assertEqual
(
42
,
int
(
proxy
))
def
test_string_to_float
(
self
):
proxy
=
self
.
_makeOne
(
"14"
)
self
.
assertEqual
(
float
(
"14"
),
float
(
proxy
))
def
test_incorrect_string_to_int
(
self
):
proxy
=
self
.
_makeOne
(
""
)
self
.
assertRaises
(
ValueError
,
int
,
proxy
)
def
test_incorrect_string_to_float
(
self
):
proxy
=
self
.
_makeOne
(
""
)
self
.
assertRaises
(
ValueError
,
float
,
proxy
)
def
test_custom_float_to_float
(
self
):
class
CustomClass
(
object
):
def
__float__
(
self
):
return
42.0
proxy
=
self
.
_makeOne
(
CustomClass
())
self
.
assertEqual
(
42.0
,
float
(
proxy
))
def
test___unicode__of_unicode
(
self
):
from
zope.proxy._compat
import
PY3
,
_u
if
PY3
:
# Gone in Python 3:
return
s
=
_u
(
'Hello,
\
u2603
'
)
proxy
=
self
.
_makeOne
(
s
)
self
.
assertEqual
(
unicode
(
proxy
),
s
)
def
test___unicode__of_custom_class
(
self
):
from
zope.proxy._compat
import
PY3
,
_u
if
PY3
:
# Gone in Python 3:
return
class
CustomClass
(
object
):
def
__unicode__
(
self
):
return
_u
(
'Hello,
\
u2603
'
)
cc
=
CustomClass
()
self
.
assertEqual
(
unicode
(
cc
),
_u
(
'Hello,
\
u2603
'
))
proxy
=
self
.
_makeOne
(
cc
)
self
.
assertEqual
(
unicode
(
proxy
),
_u
(
'Hello,
\
u2603
'
))
def
test___unicode__of_custom_class_no_unicode
(
self
):
# The default behaviour should be preserved
from
zope.proxy._compat
import
PY3
,
_u
if
PY3
:
# Gone in Python 3:
return
class
CustomClass
(
object
):
pass
cc
=
CustomClass
()
cc_unicode
=
unicode
(
cc
)
self
.
assertEqual
(
type
(
cc_unicode
),
unicode
)
proxy
=
self
.
_makeOne
(
cc
)
self
.
assertEqual
(
unicode
(
proxy
),
cc_unicode
)
def
test___call__
(
self
):
def
_foo
():
return
'FOO'
...
...
@@ -581,71 +645,6 @@ class PyProxyBaseTestCase(unittest.TestCase):
w
=
self
.
_makeOne
(
o
)
self
.
assertTrue
(
w
.
__class__
is
o
.
__class__
)
def
test_string_to_int
(
self
):
# Strings don't have the tp_number.tp_int pointer
proxy
=
self
.
_makeOne
(
"14"
)
self
.
assertEqual
(
14
,
int
(
proxy
))
def
test_custom_int_to_int
(
self
):
class
CustomClass
(
object
):
def
__int__
(
self
):
return
42
proxy
=
self
.
_makeOne
(
CustomClass
())
self
.
assertEqual
(
42
,
int
(
proxy
))
def
test_string_to_float
(
self
):
proxy
=
self
.
_makeOne
(
"14"
)
self
.
assertEqual
(
float
(
"14"
),
float
(
proxy
))
def
test_incorrect_string_to_int
(
self
):
proxy
=
self
.
_makeOne
(
""
)
self
.
assertRaises
(
ValueError
,
int
,
proxy
)
def
test_incorrect_string_to_float
(
self
):
proxy
=
self
.
_makeOne
(
""
)
self
.
assertRaises
(
ValueError
,
float
,
proxy
)
def
test_custom_float_to_float
(
self
):
class
CustomClass
(
object
):
def
__float__
(
self
):
return
42.0
proxy
=
self
.
_makeOne
(
CustomClass
())
self
.
assertEqual
(
42.0
,
float
(
proxy
))
def
test___unicode__of_unicode
(
self
):
from
zope.proxy._compat
import
PY3
,
_u
if
PY3
:
# Gone in Python 3:
return
s
=
_u
(
'Hello,
\
u2603
'
)
proxy
=
self
.
_makeOne
(
s
)
self
.
assertEqual
(
unicode
(
proxy
),
s
)
def
test___unicode__of_custom_class
(
self
):
from
zope.proxy._compat
import
PY3
,
_u
if
PY3
:
# Gone in Python 3:
return
class
CustomClass
(
object
):
def
__unicode__
(
self
):
return
_u
(
'Hello,
\
u2603
'
)
cc
=
CustomClass
()
self
.
assertEqual
(
unicode
(
cc
),
_u
(
'Hello,
\
u2603
'
))
proxy
=
self
.
_makeOne
(
cc
)
self
.
assertEqual
(
unicode
(
proxy
),
_u
(
'Hello,
\
u2603
'
))
def
test___unicode__of_custom_class_no_unicode
(
self
):
# The default behaviour should be preserved
from
zope.proxy._compat
import
PY3
,
_u
if
PY3
:
# Gone in Python 3:
return
class
CustomClass
(
object
):
pass
cc
=
CustomClass
()
cc_unicode
=
unicode
(
cc
)
self
.
assertEqual
(
type
(
cc_unicode
),
unicode
)
proxy
=
self
.
_makeOne
(
cc
)
self
.
assertEqual
(
unicode
(
proxy
),
cc_unicode
)
class
ProxyBaseTestCase
(
PyProxyBaseTestCase
):
def
_getTargetClass
(
self
):
...
...
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