Mercurial > hg > pyloader
comparison tests/objects.py @ 55:49f88cde6219
make the test wrapper more interesting (and testable)
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 08 Jun 2011 23:35:56 -0700 |
parents | f6616a5f468f |
children | cb1898f8c72a |
comparison
equal
deleted
inserted
replaced
54:f724db086125 | 55:49f88cde6219 |
---|---|
20 self.factor = a*100 + b | 20 self.factor = a*100 + b |
21 def __call__(self, number): | 21 def __call__(self, number): |
22 return number * self.factor | 22 return number * self.factor |
23 | 23 |
24 class Wrapper(object): | 24 class Wrapper(object): |
25 def __init__(self, app): | 25 def __init__(self, app, **values): |
26 self.app = app | 26 self.app = app |
27 self.values = dict([(int(i), j) for i, j in values]) | |
27 def __call__(self, *args, **kwargs): | 28 def __call__(self, *args, **kwargs): |
28 retval = self.app(*args, **kwargs) | 29 retval = self.app(*args, **kwargs) |
29 values = {1: 'one', | 30 values = {1: 'one', |
30 2: 'two', | 31 2: 'two', |
31 3: 'three'} # etc | 32 3: 'three'} # etc |
33 values.update(self.values) | |
32 if retval in values: | 34 if retval in values: |
33 return values[retval] | 35 return values[retval] |
34 return retval | 36 return retval |
35 | 37 |
36 def wrap(app): | 38 def wrap(app): |