root/galaxy-central/eggs/SQLAlchemy-0.5.6_dev_r6498-py2.6.egg/sqlalchemy/test/pickleable.py

リビジョン 3, 1.7 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1"""
2
3some objects used for pickle tests, declared in their own module so that they
4are easily pickleable.
5
6"""
7
8
9class Foo(object):
10    def __init__(self, moredata):
11        self.data = 'im data'
12        self.stuff = 'im stuff'
13        self.moredata = moredata
14    __hash__ = object.__hash__
15    def __eq__(self, other):
16        return other.data == self.data and other.stuff == self.stuff and other.moredata==self.moredata
17
18
19class Bar(object):
20    def __init__(self, x, y):
21        self.x = x
22        self.y = y
23    __hash__ = object.__hash__
24    def __eq__(self, other):
25        return other.__class__ is self.__class__ and other.x==self.x and other.y==self.y
26    def __str__(self):
27        return "Bar(%d, %d)" % (self.x, self.y)
28
29class OldSchool:
30    def __init__(self, x, y):
31        self.x = x
32        self.y = y
33    def __eq__(self, other):
34        return other.__class__ is self.__class__ and other.x==self.x and other.y==self.y
35
36class OldSchoolWithoutCompare:   
37    def __init__(self, x, y):
38        self.x = x
39        self.y = y
40   
41class BarWithoutCompare(object):
42    def __init__(self, x, y):
43        self.x = x
44        self.y = y
45    def __str__(self):
46        return "Bar(%d, %d)" % (self.x, self.y)
47
48
49class NotComparable(object):
50    def __init__(self, data):
51        self.data = data
52
53    def __hash__(self):
54        return id(self)
55
56    def __eq__(self, other):
57        return NotImplemented
58
59    def __ne__(self, other):
60        return NotImplemented
61
62
63class BrokenComparable(object):
64    def __init__(self, data):
65        self.data = data
66
67    def __hash__(self):
68        return id(self)
69
70    def __eq__(self, other):
71        raise NotImplementedError
72
73    def __ne__(self, other):
74        raise NotImplementedError
75
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。