Mercurial > hg > pyloader
annotate tests/objects.py @ 16:edecb6fbd5a7
further stubbing of ini factory
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 27 May 2011 19:00:43 -0700 |
parents | 0bea5297c156 |
children | 362912842985 |
rev | line source |
---|---|
11 | 1 """ |
2 test objects | |
3 """ | |
4 | |
5 def stringsort(*strings): | |
6 return ''.join(sorted(''.join(strings))) | |
13 | 7 |
15
0bea5297c156
introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
8 class StringMunge(object): |
0bea5297c156
introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
9 def __init__(self, prefix, delimeter=':', callback=None): |
0bea5297c156
introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
10 self.delimeter = delimeter |
0bea5297c156
introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
11 self.prefix = prefix |
0bea5297c156
introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
12 self.callback = callback |
0bea5297c156
introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
13 def __call__(self, string): |
0bea5297c156
introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
14 if self.callback: |
0bea5297c156
introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
15 string = self.callback(string) |
0bea5297c156
introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
16 return self.prefix + self.delimeter + string |
0bea5297c156
introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
17 |
13 | 18 class Foo(object): |
19 def __init__(self, a, b): | |
20 self.factor = a*100 + b | |
21 def __call__(self, number): | |
22 return number * self.factor |