comparison tests/objects.py @ 15:0bea5297c156

introduce a more betterer test
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 27 May 2011 18:56:00 -0700
parents eb81d6943f2e
children 362912842985
comparison
equal deleted inserted replaced
14:30979d82c95d 15:0bea5297c156
3 """ 3 """
4 4
5 def stringsort(*strings): 5 def stringsort(*strings):
6 return ''.join(sorted(''.join(strings))) 6 return ''.join(sorted(''.join(strings)))
7 7
8 class StringMunge(object):
9 def __init__(self, prefix, delimeter=':', callback=None):
10 self.delimeter = delimeter
11 self.prefix = prefix
12 self.callback = callback
13 def __call__(self, string):
14 if self.callback:
15 string = self.callback(string)
16 return self.prefix + self.delimeter + string
17
8 class Foo(object): 18 class Foo(object):
9 def __init__(self, a, b): 19 def __init__(self, a, b):
10 self.factor = a*100 + b 20 self.factor = a*100 + b
11 def __call__(self, number): 21 def __call__(self, number):
12 return number * self.factor 22 return number * self.factor