annotate tests/objects.py @ 22:b16d6a204ac1

stub a command line entry point
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 06 Jun 2011 07:41:23 -0700
parents 0bea5297c156
children 362912842985
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 """
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 test objects
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 def stringsort(*strings):
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 return ''.join(sorted(''.join(strings)))
13
eb81d6943f2e add another dummy object
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
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
eb81d6943f2e add another dummy object
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
18 class Foo(object):
eb81d6943f2e add another dummy object
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
19 def __init__(self, a, b):
eb81d6943f2e add another dummy object
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
20 self.factor = a*100 + b
eb81d6943f2e add another dummy object
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
21 def __call__(self, number):
eb81d6943f2e add another dummy object
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
22 return number * self.factor