~ubuntu-branches/debian/jessie/sqlalchemy/jessie

« back to all changes in this revision

Viewing changes to lib/sqlalchemy/testing/pickleable.py

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski, Jakub Wilk, Piotr Ożarowski
  • Date: 2013-07-06 20:53:52 UTC
  • mfrom: (1.4.23) (16.1.17 experimental)
  • Revision ID: package-import@ubuntu.com-20130706205352-ryppl1eto3illd79
Tags: 0.8.2-1
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Piotr Ożarowski ]
* New upstream release
* Upload to unstable
* Build depend on python3-all instead of -dev, extensions are not built for
  Python 3.X 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Classes used in pickling tests, need to be at the module level for
 
2
unpickling.
 
3
"""
 
4
 
 
5
from . import fixtures
 
6
 
 
7
 
 
8
class User(fixtures.ComparableEntity):
 
9
    pass
 
10
 
 
11
 
 
12
class Order(fixtures.ComparableEntity):
 
13
    pass
 
14
 
 
15
 
 
16
class Dingaling(fixtures.ComparableEntity):
 
17
    pass
 
18
 
 
19
 
 
20
class EmailUser(User):
 
21
    pass
 
22
 
 
23
 
 
24
class Address(fixtures.ComparableEntity):
 
25
    pass
 
26
 
 
27
 
 
28
# TODO: these are kind of arbitrary....
 
29
class Child1(fixtures.ComparableEntity):
 
30
    pass
 
31
 
 
32
 
 
33
class Child2(fixtures.ComparableEntity):
 
34
    pass
 
35
 
 
36
 
 
37
class Parent(fixtures.ComparableEntity):
 
38
    pass
 
39
 
 
40
 
 
41
class Screen(object):
 
42
 
 
43
    def __init__(self, obj, parent=None):
 
44
        self.obj = obj
 
45
        self.parent = parent
 
46
 
 
47
 
 
48
class Foo(object):
 
49
 
 
50
    def __init__(self, moredata):
 
51
        self.data = 'im data'
 
52
        self.stuff = 'im stuff'
 
53
        self.moredata = moredata
 
54
 
 
55
    __hash__ = object.__hash__
 
56
 
 
57
    def __eq__(self, other):
 
58
        return other.data == self.data and \
 
59
                other.stuff == self.stuff and \
 
60
                other.moredata == self.moredata
 
61
 
 
62
 
 
63
class Bar(object):
 
64
 
 
65
    def __init__(self, x, y):
 
66
        self.x = x
 
67
        self.y = y
 
68
 
 
69
    __hash__ = object.__hash__
 
70
 
 
71
    def __eq__(self, other):
 
72
        return other.__class__ is self.__class__ and \
 
73
            other.x == self.x and \
 
74
            other.y == self.y
 
75
 
 
76
    def __str__(self):
 
77
        return "Bar(%d, %d)" % (self.x, self.y)
 
78
 
 
79
 
 
80
class OldSchool:
 
81
 
 
82
    def __init__(self, x, y):
 
83
        self.x = x
 
84
        self.y = y
 
85
 
 
86
    def __eq__(self, other):
 
87
        return other.__class__ is self.__class__ and \
 
88
            other.x == self.x and \
 
89
            other.y == self.y
 
90
 
 
91
 
 
92
class OldSchoolWithoutCompare:
 
93
 
 
94
    def __init__(self, x, y):
 
95
        self.x = x
 
96
        self.y = y
 
97
 
 
98
 
 
99
class BarWithoutCompare(object):
 
100
 
 
101
    def __init__(self, x, y):
 
102
        self.x = x
 
103
        self.y = y
 
104
 
 
105
    def __str__(self):
 
106
        return "Bar(%d, %d)" % (self.x, self.y)
 
107
 
 
108
 
 
109
class NotComparable(object):
 
110
 
 
111
    def __init__(self, data):
 
112
        self.data = data
 
113
 
 
114
    def __hash__(self):
 
115
        return id(self)
 
116
 
 
117
    def __eq__(self, other):
 
118
        return NotImplemented
 
119
 
 
120
    def __ne__(self, other):
 
121
        return NotImplemented
 
122
 
 
123
 
 
124
class BrokenComparable(object):
 
125
 
 
126
    def __init__(self, data):
 
127
        self.data = data
 
128
 
 
129
    def __hash__(self):
 
130
        return id(self)
 
131
 
 
132
    def __eq__(self, other):
 
133
        raise NotImplementedError
 
134
 
 
135
    def __ne__(self, other):
 
136
        raise NotImplementedError