annotate tests/test_factory.txt @ 94:65ef62208d05

boldly moving forward
author Jeff Hammel <k0scist@gmail.com>
date Tue, 03 Nov 2020 10:44:45 -0800
parents 418289c0fe3c
children
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 Test pyloader's Factory
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 =======================
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 Boilerplate::
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 >>> import os
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 >>> from pyloader.factory import PyFactory
15
0bea5297c156 introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
8 >>> objects = os.path.join(here, 'objects.py')
11
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 Construct a factory::
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 >>> factory = PyFactory()
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 Make a configuration::
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15
85
418289c0fe3c STUB: tests/test_call.txt tests/test_factory.txt
Jeff Hammel <k0scist@gmail.com>
parents: 32
diff changeset
16 >>> config = {'': {'path': objects + ':stringsort', 'args': ['foo', 'bar']}}
11
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 Load it::
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 >>> factory.configure(config)
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 Get the thing::
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 >>> factory.load()
ff272dcd5cd8 we have a passing test
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 'abfoor'
15
0bea5297c156 introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
26
0bea5297c156 introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
27 Now lets try something better!::
0bea5297c156 introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
28
0bea5297c156 introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
29 >>> config = {'': {'path': objects + ':StringMunge', 'kwargs': {'prefix': 'PRE', 'callback': '%(callback)s'}},
0bea5297c156 introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
30 ... 'callback': {'path': objects + ':stringsort'} }
0bea5297c156 introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
31 >>> factory.configure(config)
0bea5297c156 introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
32 >>> obj = factory.load()
0bea5297c156 introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
33 >>> obj('foobar')
0bea5297c156 introduce a more betterer test
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
34 'PRE:abfoor'