Skip to content

Commit

Permalink
pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed May 5, 2013
1 parent 6ac0f5b commit 08a96ad
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/Persistence/tests/test_ec.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from Persistence import Persistent


def test_basic():
"""
Expand Down Expand Up @@ -94,6 +95,7 @@ class init called
1
"""


def test_mixing():
"""Test working with a classic class
Expand Down Expand Up @@ -140,9 +142,9 @@ class init called
>>> c.o2 = o2
>>> int(c.o2 == ((o2, c), 42))
1
"""


def proper_error_on_deleattr():
"""
Florent Guillaume wrote:
Expand Down Expand Up @@ -174,13 +176,15 @@ def proper_error_on_deleattr():
raise AttributeError.
"""


def test__basicnew__():
"""
>>> x = Simple.__basicnew__()
>>> x.__dict__
{}
"""


def test_setattr_on_extension_type():
"""
>>> for name in 'x', '_x', 'x_', '__x_y__', '___x__', '__x___', '_x_':
Expand Down Expand Up @@ -225,6 +229,7 @@ def test_setattr_on_extension_type():
"""


def test_class_creation_under_stress():
"""
>>> for i in range(100):
Expand All @@ -243,12 +248,14 @@ def test_class_creation_under_stress():
"""


def print_dict(d):
d = d.items()
d.sort()
print '{%s}' % (', '.join(
[('%r: %r' % (k, v)) for (k, v) in d]
))
))


def cmpattrs(self, other, *attrs):
for attr in attrs:
Expand All @@ -259,6 +266,7 @@ def cmpattrs(self, other, *attrs):
return c
return 0


class Simple(Persistent):
def __init__(self, name, **kw):
self.__name__ = name
Expand All @@ -269,6 +277,7 @@ def __init__(self, name, **kw):
def __cmp__(self, other):
return cmpattrs(self, other, '__class__', *(self.__dict__.keys()))


def test_basic_pickling():
"""
>>> x = Simple('x', aaa=1, bbb='foo')
Expand Down Expand Up @@ -302,6 +311,7 @@ def test_basic_pickling():
"""


class Custom(Simple):

def __new__(cls, x, y):
Expand Down Expand Up @@ -348,20 +358,23 @@ def test_pickling_w_overrides():
"""


class Slotted(Persistent):
__slots__ = 's1', 's2', '_p_splat', '_v_eek'

def __init__(self, s1, s2):
self.s1, self.s2 = s1, s2
self._v_eek = 1
self._p_splat = 2


class SubSlotted(Slotted):
__slots__ = 's3', 's4'

def __init__(self, s1, s2, s3):
Slotted.__init__(self, s1, s2)
self.s3 = s3


def __cmp__(self, other):
return cmpattrs(self, other, '__class__', 's1', 's2', 's3', 's4')

Expand Down Expand Up @@ -402,6 +415,7 @@ def test_pickling_w_slots_only():
"""


class SubSubSlotted(SubSlotted):

def __init__(self, s1, s2, s3, **kw):
Expand All @@ -415,6 +429,7 @@ def __cmp__(self, other):
'__class__', 's1', 's2', 's3', 's4',
*(self.__dict__.keys()))


def test_pickling_w_slots():
"""
>>> x = SubSubSlotted('x', 'y', 'z', aaa=1, bbb='foo')
Expand Down Expand Up @@ -453,6 +468,7 @@ def test_pickling_w_slots():
"""


def test_pickling_w_slots_w_empty_dict():
"""
>>> x = SubSubSlotted('x', 'y', 'z')
Expand Down Expand Up @@ -488,8 +504,8 @@ def test_pickling_w_slots_w_empty_dict():
1
>>> pickle.loads(pickle.dumps(x, 2)) == x
1
"""


def test_suite():
return DocTestSuite()

0 comments on commit 08a96ad

Please sign in to comment.