Commit adf40692 authored by Tres Seaver's avatar Tres Seaver

Further test cleanup.

parent f7392980
...@@ -32,10 +32,6 @@ class ProxyBaseTestCase(unittest.TestCase): ...@@ -32,10 +32,6 @@ class ProxyBaseTestCase(unittest.TestCase):
from zope.proxy import ProxyBase from zope.proxy import ProxyBase
return ProxyBase return ProxyBase
def setUp(self):
self.x = Thing()
self.p = self.new_proxy(self.x)
def new_proxy(self, o): def new_proxy(self, o):
return self.proxy_class(o) return self.proxy_class(o)
...@@ -81,6 +77,8 @@ class ProxyBaseTestCase(unittest.TestCase): ...@@ -81,6 +77,8 @@ class ProxyBaseTestCase(unittest.TestCase):
self.assertEquals(list(p), list('another')) self.assertEquals(list(p), list('another'))
def test_proxy_attributes(self): def test_proxy_attributes(self):
class Thing:
"""This class is expected to be a classic class."""
o = Thing() o = Thing()
o.foo = 1 o.foo = 1
w = self.new_proxy(o) w = self.new_proxy(o)
...@@ -96,6 +94,8 @@ class ProxyBaseTestCase(unittest.TestCase): ...@@ -96,6 +94,8 @@ class ProxyBaseTestCase(unittest.TestCase):
from zope.proxy._compat import PY3 from zope.proxy._compat import PY3
# Proxies of old-style classes can't be pickled. # Proxies of old-style classes can't be pickled.
if not PY3: # No old-style classes in Python 3. if not PY3: # No old-style classes in Python 3.
class Thing:
"""This class is expected to be a classic class."""
w = self.new_proxy(Thing()) w = self.new_proxy(Thing())
self.assertRaises(pickle.PicklingError, self.assertRaises(pickle.PicklingError,
pickle.dumps, w) pickle.dumps, w)
...@@ -758,34 +758,24 @@ class Test_nonOverridable(unittest.TestCase): ...@@ -758,34 +758,24 @@ class Test_nonOverridable(unittest.TestCase):
self.assertEqual(proxy.what(), 'PROXY') self.assertEqual(proxy.what(), 'PROXY')
class Thing:
"""This class is expected to be a classic class."""
class Comparable(object): class Comparable(object):
def __init__(self, value): def __init__(self, value):
self.value = value self.value = value
def __eq__(self, other): def __eq__(self, other):
if hasattr(other, "value"): return self.value == getattr(other, 'value', other)
other = other.value
return self.value == other
def __ne__(self, other): def __ne__(self, other):
return not self.__eq__(other) return not self.__eq__(other)
def __lt__(self, other): def __lt__(self, other):
if hasattr(other, "value"): return self.value < getattr(other, 'value', other)
other = other.value
return self.value < other
def __ge__(self, other): def __ge__(self, other):
return not self.__lt__(other) return not self.__lt__(other)
def __le__(self, other): def __le__(self, other):
if hasattr(other, "value"): return self.value <= getattr(other, 'value', other)
other = other.value
return self.value <= other
def __gt__(self, other): def __gt__(self, other):
return not self.__le__(other) return not self.__le__(other)
...@@ -795,7 +785,6 @@ class Comparable(object): ...@@ -795,7 +785,6 @@ class Comparable(object):
def test_suite(): def test_suite():
from doctest import DocTestSuite
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(ModuleConformanceCase), unittest.makeSuite(ModuleConformanceCase),
unittest.makeSuite(ProxyBaseTestCase), unittest.makeSuite(ProxyBaseTestCase),
...@@ -807,5 +796,4 @@ def test_suite(): ...@@ -807,5 +796,4 @@ def test_suite():
unittest.makeSuite(Test_queryInnerProxy), unittest.makeSuite(Test_queryInnerProxy),
unittest.makeSuite(Test_sameProxiedObjects), unittest.makeSuite(Test_sameProxiedObjects),
unittest.makeSuite(Test_nonOverridable), unittest.makeSuite(Test_nonOverridable),
DocTestSuite(),
)) ))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment