Mercurial > hg > pyloader
view tests/test_ini.txt @ 41:2c228e3cd6d8
split reading and interpreting the .ini into different functions
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 08 Jun 2011 17:50:05 -0700 |
parents | f6616a5f468f |
children | f724db086125 |
line wrap: on
line source
Test IniFactory =============== Let's test the .ini factory:: >>> import os >>> from pyloader.factory import IniFactory >>> inifile = os.path.join(here, 'test.ini') >>> inifactory = IniFactory(inifile) Load it up:: >>> object = inifactory.load() >>> 'objects.py.StringMunge' in repr(object.__class__) True Call it:: >>> object('foobar') 'PRE!!!abfoor' You can also just load the callback:: >>> callback = inifactory.load('callback') >>> callback('foo', 'bar') 'abfoor' Lets test the Fibonnaci sequence:: >>> fib = inifactory.load('fibonacci') >>> fib(0) == fib(1) == 1 True >>> [fib(i) for i in range(5)] [1, 1, 2, 3, 5]