annotate tests/test_ini.txt @ 67:236af713bbc0

move setting the configuration to later so that we can easily move around sect
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 09 Jun 2011 09:25:54 -0700
parents f0f3525486db
children b9d9a94bfa19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 Test IniFactory
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 ===============
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 Let's test the .ini factory::
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 >>> import os
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 >>> from pyloader.factory import IniFactory
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 >>> inifile = os.path.join(here, 'test.ini')
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 >>> inifactory = IniFactory(inifile)
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 Load it up::
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 >>> object = inifactory.load()
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 >>> 'objects.py.StringMunge' in repr(object.__class__)
b98cc94ffcfa split IniFactory tests to their own file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 True
33
48f61cea0a3c test calling the thing
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
16
48f61cea0a3c test calling the thing
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
17 Call it::
48f61cea0a3c test calling the thing
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
18
48f61cea0a3c test calling the thing
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
19 >>> object('foobar')
48f61cea0a3c test calling the thing
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
20 'PRE!!!abfoor'
34
a9eaf65d82c6 test loading a different section
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
21
a9eaf65d82c6 test loading a different section
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
22 You can also just load the callback::
a9eaf65d82c6 test loading a different section
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
23
a9eaf65d82c6 test loading a different section
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
24 >>> callback = inifactory.load('callback')
a9eaf65d82c6 test loading a different section
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
25 >>> callback('foo', 'bar')
a9eaf65d82c6 test loading a different section
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
26 'abfoor'
38
f6616a5f468f test fibonacci sequence
Jeff Hammel <jhammel@mozilla.com>
parents: 34
diff changeset
27
f6616a5f468f test fibonacci sequence
Jeff Hammel <jhammel@mozilla.com>
parents: 34
diff changeset
28 Lets test the Fibonnaci sequence::
f6616a5f468f test fibonacci sequence
Jeff Hammel <jhammel@mozilla.com>
parents: 34
diff changeset
29
f6616a5f468f test fibonacci sequence
Jeff Hammel <jhammel@mozilla.com>
parents: 34
diff changeset
30 >>> fib = inifactory.load('fibonacci')
f6616a5f468f test fibonacci sequence
Jeff Hammel <jhammel@mozilla.com>
parents: 34
diff changeset
31 >>> fib(0) == fib(1) == 1
f6616a5f468f test fibonacci sequence
Jeff Hammel <jhammel@mozilla.com>
parents: 34
diff changeset
32 True
f6616a5f468f test fibonacci sequence
Jeff Hammel <jhammel@mozilla.com>
parents: 34
diff changeset
33 >>> [fib(i) for i in range(5)]
f6616a5f468f test fibonacci sequence
Jeff Hammel <jhammel@mozilla.com>
parents: 34
diff changeset
34 [1, 1, 2, 3, 5]
54
f724db086125 houston, we have a pyloader
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
35
59
6b48dee5b92b add a failing test for wrapper of type [foo:@:fibonacci]
Jeff Hammel <jhammel@mozilla.com>
parents: 54
diff changeset
36 Now let's test a simple wrapper, [readable-fibonacci:@:%(here)s/objects.py:fib]::
54
f724db086125 houston, we have a pyloader
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
37
f724db086125 houston, we have a pyloader
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
38 >>> fib = inifactory.load('readable-fibonacci')
f724db086125 houston, we have a pyloader
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
39 >>> [fib(i) for i in range(5)]
f724db086125 houston, we have a pyloader
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
40 ['one', 'one', 'two', 'three', 5]
59
6b48dee5b92b add a failing test for wrapper of type [foo:@:fibonacci]
Jeff Hammel <jhammel@mozilla.com>
parents: 54
diff changeset
41
64
f0f3525486db test calling the section wrapper, [foo:@:fibonacci]
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
42 A different kind of wrapper, wrapping a section, [foo:@:fibonacci]::
59
6b48dee5b92b add a failing test for wrapper of type [foo:@:fibonacci]
Jeff Hammel <jhammel@mozilla.com>
parents: 54
diff changeset
43
6b48dee5b92b add a failing test for wrapper of type [foo:@:fibonacci]
Jeff Hammel <jhammel@mozilla.com>
parents: 54
diff changeset
44 >>> fib = inifactory.load('foo')
61
926caecf385d check in a passing test for a change
Jeff Hammel <jhammel@mozilla.com>
parents: 59
diff changeset
45 >>> 'objects.py.Wrapper' in repr(fib)
926caecf385d check in a passing test for a change
Jeff Hammel <jhammel@mozilla.com>
parents: 59
diff changeset
46 True
926caecf385d check in a passing test for a change
Jeff Hammel <jhammel@mozilla.com>
parents: 59
diff changeset
47 >>> inifactory.config['foo']['kwargs']['app']
926caecf385d check in a passing test for a change
Jeff Hammel <jhammel@mozilla.com>
parents: 59
diff changeset
48 '%(fibonacci)s'
64
f0f3525486db test calling the section wrapper, [foo:@:fibonacci]
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
49 >>> [fib(i) for i in range(6)]
f0f3525486db test calling the section wrapper, [foo:@:fibonacci]
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
50 ['one', 'one', 'two', 'three', 5, 8]