Mercurial > hg > pyloader
changeset 11:ff272dcd5cd8
we have a passing test
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 27 May 2011 07:02:27 -0700 |
parents | ba2355d57998 |
children | d50d5237e82d |
files | pyloader/factory.py tests/objects.py tests/test.py tests/test_factory.txt |
diffstat | 4 files changed, 37 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/pyloader/factory.py Fri May 27 06:40:15 2011 -0700 +++ b/pyloader/factory.py Fri May 27 07:02:27 2011 -0700 @@ -36,7 +36,7 @@ self.seen.add(name) # get section - section = config[name] + section = self.config[name] assert 'path' in section # load object @@ -53,10 +53,14 @@ # interpolate arguments if args: - args = [self.iterpolate(arg) for arg in args] + args = [self.interpolate(arg) for arg in args] + else: + args = [] if kwargs: kwargs = dict([(key, self.interpolate(value)) for key, value in kwargs.items()]) + else: + kwargs = {} # invoke self.parsed[name] = obj(*args, **kwargs)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/objects.py Fri May 27 07:02:27 2011 -0700 @@ -0,0 +1,6 @@ +""" +test objects +""" + +def stringsort(*strings): + return ''.join(sorted(''.join(strings)))
--- a/tests/test.py Fri May 27 06:40:15 2011 -0700 +++ b/tests/test.py Fri May 27 07:02:27 2011 -0700 @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -doctest runner +doctest runner for pyloader """ import doctest
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_factory.txt Fri May 27 07:02:27 2011 -0700 @@ -0,0 +1,24 @@ +Test pyloader's Factory +======================= + +Boilerplate:: + + >>> import os + >>> from pyloader.factory import PyFactory + +Construct a factory:: + + >>> factory = PyFactory() + +Make a configuration:: + + >>> config = {'': {'path': os.path.join(here, 'objects.py:stringsort'), 'args': ['foo', 'bar']}} + +Load it:: + + >>> factory.configure(config) + +Get the thing:: + + >>> factory.load() + 'abfoor'