2
# SchoolTool - common information systems platform for school administration
3
# Copyright (c) 2005 Shuttleworth Foundation
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
"""Testing setup for schooltool.requirement
23
__docformat__ = 'reStructuredText'
25
from zope.interface import Interface
26
from zope.component import provideAdapter
27
from zope.keyreference.interfaces import IKeyReference
29
from schooltool.requirement import requirement, interfaces, evaluation
31
class KeyReferenceStub(object):
32
"""A stub implementation to allow testing of evaluations."""
34
key_type_id = 'tests.path'
36
def __init__(self, context):
37
self.context = context
43
return id(self.context)
45
def __cmp__(self, ref):
46
return cmp((self.key_type_id, self.__hash__()),
47
(ref.key_type_id, ref.__hash__()))
49
def setUpRequirement(test=None):
50
provideAdapter(requirement.getRequirement,
52
interfaces.IRequirement)
54
def setUpEvaluation(test=None):
55
provideAdapter(evaluation.getEvaluations,
57
interfaces.IEvaluations)
58
provideAdapter(KeyReferenceStub,
63
Monkey patch the decimal module to get the same output on python2.6
64
See http://mail.python.org/pipermail/python-dev/2008-July/081420.html
67
decimal.Decimal.__repr__ = lambda s: 'Decimal("%s")' % str(s)