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
fadaad25
Commit
fadaad25
authored
Nov 21, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid 'p' as a variable name for debugging ease.
parent
4dc6f0c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
49 deletions
+50
-49
src/zope/proxy/tests/test_proxy.py
src/zope/proxy/tests/test_proxy.py
+50
-49
No files found.
src/zope/proxy/tests/test_proxy.py
View file @
fadaad25
...
...
@@ -63,8 +63,8 @@ class PyProxyBaseTestCase(unittest.TestCase):
def
__new__
(
cls
,
*
args
,
**
kwds
):
return
super
(
MyProxy2
,
cls
).
__new__
(
cls
,
'value'
)
p
=
MyProxy2
(
'splat!'
)
self
.
assertEqual
(
list
(
p
),
list
(
'splat!'
))
p
roxy
=
MyProxy2
(
'splat!'
)
self
.
assertEqual
(
list
(
p
roxy
),
list
(
'splat!'
))
class
MyProxy3
(
MyProxy2
):
def
__init__
(
self
,
arg
):
...
...
@@ -72,14 +72,14 @@ class PyProxyBaseTestCase(unittest.TestCase):
raise
AssertionError
(
"list(self) != list('value')"
)
super
(
MyProxy3
,
self
).
__init__
(
'another'
)
p
=
MyProxy3
(
'notused'
)
self
.
assertEqual
(
list
(
p
),
list
(
'another'
))
p
roxy
=
MyProxy3
(
'notused'
)
self
.
assertEqual
(
list
(
p
roxy
),
list
(
'another'
))
def
test___call__
(
self
):
def
_foo
():
return
'FOO'
p
=
self
.
_makeOne
(
_foo
)
self
.
assertEqual
(
p
(),
'FOO'
)
p
roxy
=
self
.
_makeOne
(
_foo
)
self
.
assertEqual
(
p
roxy
(),
'FOO'
)
def
test_callable
(
self
):
from
zope.proxy._compat
import
PY3
...
...
@@ -90,14 +90,14 @@ class PyProxyBaseTestCase(unittest.TestCase):
def
test___repr__
(
self
):
def
_foo
():
return
'FOO'
p
=
self
.
_makeOne
(
_foo
)
self
.
assertTrue
(
repr
(
p
).
startswith
(
'<function _foo'
))
p
roxy
=
self
.
_makeOne
(
_foo
)
self
.
assertTrue
(
repr
(
p
roxy
).
startswith
(
'<function _foo'
))
def
test___str__
(
self
):
def
_foo
():
return
'FOO'
p
=
self
.
_makeOne
(
_foo
)
self
.
assertTrue
(
str
(
p
).
startswith
(
'<function _foo'
))
p
roxy
=
self
.
_makeOne
(
_foo
)
self
.
assertTrue
(
str
(
p
roxy
).
startswith
(
'<function _foo'
))
def
test___unicode__
(
self
):
from
zope.proxy._compat
import
PY3
...
...
@@ -105,8 +105,8 @@ class PyProxyBaseTestCase(unittest.TestCase):
return
def
_foo
():
return
'FOO'
p
=
self
.
_makeOne
(
_foo
)
self
.
assertTrue
(
unicode
(
p
).
startswith
(
'<function _foo'
))
p
roxy
=
self
.
_makeOne
(
_foo
)
self
.
assertTrue
(
unicode
(
p
roxy
).
startswith
(
'<function _foo'
))
def
test___reduce___via_pickling
(
self
):
import
pickle
...
...
@@ -582,16 +582,16 @@ class Test_py_getProxiedObject(unittest.TestCase):
class
C
(
object
):
pass
c
=
C
()
p
=
self
.
_makeProxy
(
c
)
self
.
assertTrue
(
self
.
_callFUT
(
p
)
is
c
)
p
roxy
=
self
.
_makeProxy
(
c
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy
)
is
c
)
def
test_nested_proxy
(
self
):
class
C
(
object
):
pass
c
=
C
()
p
=
self
.
_makeProxy
(
c
)
p
2
=
self
.
_makeProxy
(
p
)
self
.
assertTrue
(
self
.
_callFUT
(
p
2
)
is
p
)
p
roxy
=
self
.
_makeProxy
(
c
)
p
roxy2
=
self
.
_makeProxy
(
proxy
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy2
)
is
proxy
)
class
Test_getProxiedObject
(
Test_py_getProxiedObject
):
...
...
@@ -628,11 +628,11 @@ class Test_py_setProxiedObject(unittest.TestCase):
self
.
name
=
name
c1
=
C
(
'c1'
)
c2
=
C
(
'c2'
)
p
=
self
.
_makeProxy
(
c1
)
self
.
assertEqual
(
p
.
name
,
'c1'
)
old
=
self
.
_callFUT
(
p
,
c2
)
p
roxy
=
self
.
_makeProxy
(
c1
)
self
.
assertEqual
(
p
roxy
.
name
,
'c1'
)
old
=
self
.
_callFUT
(
p
roxy
,
c2
)
self
.
assertTrue
(
old
is
c1
)
self
.
assertEqual
(
p
.
name
,
'c2'
)
self
.
assertEqual
(
p
roxy
.
name
,
'c2'
)
def
test_w_nested_proxy
(
self
):
class
C
(
object
):
...
...
@@ -641,12 +641,12 @@ class Test_py_setProxiedObject(unittest.TestCase):
c1
=
C
(
'c1'
)
c2
=
C
(
'c2'
)
p1
=
self
.
_makeProxy
(
c1
)
p2
=
self
.
_makeProxy
(
c2
)
p
=
self
.
_makeProxy
(
p1
)
self
.
assertEqual
(
p
.
name
,
'c1'
)
old
=
self
.
_callFUT
(
p
,
p
2
)
p
roxy
2
=
self
.
_makeProxy
(
c2
)
p
roxy
=
self
.
_makeProxy
(
p1
)
self
.
assertEqual
(
p
roxy
.
name
,
'c1'
)
old
=
self
.
_callFUT
(
p
roxy
,
proxy
2
)
self
.
assertTrue
(
old
is
p1
)
self
.
assertEqual
(
p
.
name
,
'c2'
)
self
.
assertEqual
(
p
roxy
.
name
,
'c2'
)
class
Test_setProxiedObject
(
Test_py_setProxiedObject
):
...
...
@@ -916,11 +916,11 @@ class Test_py_queryInnerProxy(unittest.TestCase):
pass
c
=
C
()
p1
=
P1
(
c
)
p2
=
P2
(
p1
)
self
.
assertTrue
(
self
.
_callFUT
(
p2
,
P1
)
is
p1
)
self
.
assertTrue
(
self
.
_callFUT
(
p2
,
P1
,
42
)
is
p1
)
self
.
assertTrue
(
self
.
_callFUT
(
p
2
,
P2
)
is
p
2
)
self
.
assertTrue
(
self
.
_callFUT
(
p
2
,
P2
,
42
)
is
p
2
)
p
roxy
2
=
P2
(
p1
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy
2
,
P1
)
is
p1
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy
2
,
P1
,
42
)
is
p1
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy2
,
P2
)
is
proxy
2
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy2
,
P2
,
42
)
is
proxy
2
)
def
test_re_nested_proxy
(
self
):
class
P1
(
self
.
_proxyClass
()):
...
...
@@ -931,12 +931,12 @@ class Test_py_queryInnerProxy(unittest.TestCase):
pass
c
=
C
()
p1
=
P1
(
c
)
p2
=
P2
(
p1
)
p
3
=
P1
(
p
2
)
self
.
assertTrue
(
self
.
_callFUT
(
p3
,
P1
)
is
p1
)
self
.
assertTrue
(
self
.
_callFUT
(
p3
,
P1
,
42
)
is
p1
)
self
.
assertTrue
(
self
.
_callFUT
(
p
3
,
P2
)
is
p
2
)
self
.
assertTrue
(
self
.
_callFUT
(
p
3
,
P2
,
42
)
is
p
2
)
p
roxy
2
=
P2
(
p1
)
p
roxy3
=
P1
(
proxy
2
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy
3
,
P1
)
is
p1
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy
3
,
P1
,
42
)
is
p1
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy3
,
P2
)
is
proxy
2
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy3
,
P2
,
42
)
is
proxy
2
)
class
Test_queryInnerProxy
(
unittest
.
TestCase
):
...
...
@@ -970,16 +970,16 @@ class Test_py_removeAllProxies(unittest.TestCase):
class
C
(
object
):
pass
c
=
C
()
p
=
self
.
_makeProxy
(
c
)
self
.
assertTrue
(
self
.
_callFUT
(
p
)
is
c
)
p
roxy
=
self
.
_makeProxy
(
c
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy
)
is
c
)
def
test_nested_proxy
(
self
):
class
C
(
object
):
pass
c
=
C
()
p
=
self
.
_makeProxy
(
c
)
p
2
=
self
.
_makeProxy
(
p
)
self
.
assertTrue
(
self
.
_callFUT
(
p2
)
is
c
)
p
roxy
=
self
.
_makeProxy
(
c
)
p
roxy2
=
self
.
_makeProxy
(
proxy
)
self
.
assertTrue
(
self
.
_callFUT
(
p
roxy
2
)
is
c
)
class
Test_removeAllProxies
(
unittest
.
TestCase
):
...
...
@@ -1010,19 +1010,20 @@ class Test_ProxyIterator(unittest.TestCase):
class
C
(
object
):
pass
c
=
C
()
p
=
ProxyBase
(
c
)
self
.
assertEqual
(
list
(
self
.
_callFUT
(
p
)),
[
p
,
c
])
p
roxy
=
ProxyBase
(
c
)
self
.
assertEqual
(
list
(
self
.
_callFUT
(
p
roxy
)),
[
proxy
,
c
])
def
test_w_nested_proxies
(
self
):
from
zope.proxy
import
ProxyBase
class
C
(
object
):
pass
c
=
C
()
p
=
ProxyBase
(
c
)
p2
=
ProxyBase
(
p
)
p3
=
ProxyBase
(
p2
)
p4
=
ProxyBase
(
p3
)
self
.
assertEqual
(
list
(
self
.
_callFUT
(
p4
)),
[
p4
,
p3
,
p2
,
p
,
c
])
proxy
=
ProxyBase
(
c
)
proxy2
=
ProxyBase
(
proxy
)
proxy3
=
ProxyBase
(
proxy2
)
proxy4
=
ProxyBase
(
proxy3
)
self
.
assertEqual
(
list
(
self
.
_callFUT
(
proxy4
)),
[
proxy4
,
proxy3
,
proxy2
,
proxy
,
c
])
class
Test_nonOverridable
(
unittest
.
TestCase
):
...
...
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