-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathREADME
1194 lines (854 loc) · 30.5 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
***********************************************
PBBT -- Pluggable Black-Box Testing toolkit
***********************************************
.. contents:: Table of Contents
Overview
========
PBBT is a regression test harness for *black-box testing*. It is
suitable for testing complex software components with well-defined input
and output interfaces.
::
input +----------+ output
o--------> | Software | --------->o
+----------+
In black-box testing, a *test case* is a combination of *input* and
expected *output* data. The test harness executes the software with the
given input and verifies that the produced output coincides with the
expected output.
Black-box testing could be implemented for many different types of
software. For example,
* *a database system:* the input is a SQL statement, the output is a set
of records;
* *a web service:* the input is an HTTP request, the output is an HTTP
response;
* *a command-line utility:* the input is a sequence of command-line
parameters and ``stdin``, the output is ``stdout``;
* *a GUI application:* different approaches are possible; for instance,
the input could be a sequence of user actions, and the output could be
the state of a particular widget.
PBBT is a Python library and an application which allows you to:
* use built-in test types for testing command-line scripts and Python
code;
* register custom test types;
* prepare test input in a succinct YAML_ format;
* in the *train* mode, run the test cases and record expected output;
* in the *check* mode, run the test cases and verify that the produced
output coincides with the pre-recorded expected output.
PBBT is a free software released under MIT license. PBBT is created by
Clark C. Evans and Kirill Simonov from `Prometheus Research, LLC`_.
Using PBBT
==========
To install PBBT, you can use pip_ package manager::
# pip install pbbt
This command downloads and installs the latest version of PBBT from
`Python Package Index`_. After successful installation, you should be
able to import ``pbbt`` Python module and run ``pbbt`` command-line
utility.
To start using PBBT, you need to create a file with input data. For
example, create ``input.yaml`` with the following content::
py: |
print "Hello, World!"
This file is in YAML_ format, which is a data serialization language
similar to JSON_, and, in fact, a superset of JSON. The file above
could be represented in JSON as::
{ "py": "print \"Hello, World!\"\n" }
For description of YAML syntax and semantics, see http://yaml.org/.
Next, execute PBBT in *training* mode to generate expected output data.
Run::
$ pbbt input.yaml output.yaml --train
and accept new output when asked. PBBT will write output data to
``output.yaml``::
py: print-hello-world
stdout: |
Hello, World!
Now you can start PBBT in *checking* mode, in which it executes test
cases and verifies that expected and actual output data coincide::
$ pbbt input.yaml output.yaml
To add more test cases to ``input.yaml``, you need to convert it to a
*test suite*::
title: My Tests
tests:
- py: |
print "Hello, World!"
- sh: echo Hello, World!
The file now contains a test suite *My Tests* with two test cases: one
as in the previous example, and another that executes a shell command
``echo Hello, World!``::
sh: echo Hello, World!
The output of this test case is ``stdout`` produced by the shell
command. To record expected output, run ``pbbt`` in training mode
again.
Built-in Test Types
===================
Out of the box, PBBT supports a small set of predefined test types:
* test Python code;
* test a shell command;
* file manipulation tests.
Also available are special test types:
* test suite;
* include;
* conditional variables.
* gateway to other test systems.
Each test type defines the structure of input and output records, that
is, the set of mandatory and optional fields and the type of field
values. In this section, we list all available test types and describe
their input fields.
Common Fields
-------------
The following optional fields are available for all test types where
they make sense:
``skip``: ``true`` or ``false``
On ``true``, skip this test case.
``if``: variable, list of variables or Python expression
On a *variable name*, run this test case only if the variable is
defined and not false.
On a *list of variables*, run this test case only if at least one
variable is defined and not false.
On a *Python expression*, run this test case if the expression
evaluates to true. You can use any conditional variables in the
expression.
``unless``: variable, list of variables or Python expression
On a *variable name*, skip this test case if the variable is defined
and not false.
On a *list of variables*, skip this test case if at least one
variable is defined and not false.
On a *Python expression*, skip this test case if the expression
evaluates to true. You can use any conditional variables in the
expression.
``ignore``: ``true``, ``false`` or regular expression
On ``true``, permit the actual and expected output to be unequal.
The test case must still execute without any errors.
On a *regular expression*, pre-process the actual and expected
output before comparing them:
1. Run the regular expression against the output data and find
all matches.
2. If the regular expression does not contain ``()`` subgroups,
erase all the matches from the output.
3. If the regular expression contains one or more ``()`` subgroups,
erase the content of the subgroups from the output.
The regular expression is compiled with ``MULTILINE`` and
``VERBOSE`` flags.
Example::
title: Integration with MySQL
if: has_mysql
tests:
- set:
MYSQL_HOST: localhost
MYSQL_PORT: 3306
unless: [MYSQL_HOST, MYSQL_PORT]
- read: /etc/mysql/my.cnf
if: MYSQL_HOST == 'localhost'
- py: test-scalar-types.py
ignore: |
^Today:.(\d\d\d\d)-(\d\d)-(\d\d)$
- py: test-array-types.py
skip: true # No array type in MySQL
Test Suite
----------
A test suite is a collection of test cases.
A suite may contain other suites and thus all test suites form a tree
structure. A *path* formed from suite identifiers can uniquely locate
any suite. We use file-system notation for suite paths (e.g.
``/path/to/suite``).
Fields:
``title``: text
The title of the suite.
``suite``: identifier (optional)
The identifier of the suite. If not set, generated from the title.
``tests``: list of input records
The content of the suite.
``output``: path (optional)
If set, the expected output of the suite is loaded from the given
file.
Example::
title: All Tests
suite: all
output: output.yaml
tests:
- py: ./test/core.py
- py: ./test/ext.py
- title: Database Tests
tests:
- py: ./test/sqlite.py
- py: ./test/pgsql.py
- py: ./test/mysql.py
In this example, the path to the *Database Tests* suite is
``/all/database-tests``.
Conditional Variables
---------------------
This test case defines a conditional variable.
Variables could be used in ``if`` and ``unless`` clauses to
conditionally enable or disable a test case. Variables could also be
set or read in Python tests via a global dictionary ``__pbbt__``.
Conditional variables could also be set from command line using ``-D``
option.
Setting a conditional variable affects all subsequent test cases within
the same test suite. Variable values are reset on exit from the suite.
Fields:
``set``: variable or dictionary of variables
On a *variable name*, set the value of the given variable to
``True``.
On a *dictionary*, set the values of the given variables.
Example::
title: MySQL Tests
tests:
- set: MYSQL
- set:
MYSQL_HOST: localhost
MYSQL_PORT: 3306
unless: [MYSQL_HOST, MYSQL_PORT]
- py: |
# Determine the version of the MySQL server
import MySQLdb
connection = MySQLdb.connect(host=__pbbt__['MYSQL_HOST'],
port=int(__pbbt__['MYSQL_PORT']),
db='mysql')
cursor = connection.cursor()
cursor.execute("""SELECT VERSION()""")
version_string = cursor.fetchone()[0]
version = tuple(map(int, version_string.split('-')[0].split('.')))
__pbbt__['MYSQL_VERSION'] = version
- py: test-ddl.py
- py: test-dml.py
- py: test-select.py
- py: test-new-features.py
if: MYSQL_VERSION >= (5, 5)
Include Test
------------
This test case loads and executes a test case from a file.
Fields:
``include``: path
The file to load. The file should contain an input test record in
YAML format.
Example::
title: All Tests
tests:
- include: test/core.yaml
- include: test/ext.yaml
- include: test/sqlite.yaml
- include: test/pgsql.yaml
- include: test/mysql.yaml
Python Code
-----------
This test case executes Python code and produces ``stdout``.
Fields:
``py``: path or Python code
On *Python code*, the source code to execute.
On a *file name*, the file which contains source code to execute.
``stdin``: text (optional)
Content of the standard input.
``except``: exception type (optional)
If set, indicates that the code is expected to raise an exception of
the given type.
Example::
title: Python tests
tests:
- py: hello.py
- py: &sum |
# Sum of two numbers
import sys
a = int(sys.stdin.readline())
b = int(sys.stdin.readline())
c = a+b
sys.stdout.write("%s\n" % c)
stdin: |
2
2
- py: *sum
stdin: |
1
-5
- py: *sum
stdin: |
one
three
except: ValueError
Note that we use a YAML anchor (denoted by ``&sum``) and aliases
(denoted by ``*sum``) to use the same piece of code in several tests.
Shell Command
-------------
This test case executes a shell command and produces ``stdout``.
Fields:
``sh``: command or executable with a list of parameters
The shell command to execute.
``stdin``: text (optional)
Content of the standard input.
``cd``: path (optional)
Change the current working directory to the given path before
executing the command.
``environ``: dictionary of variables (optional)
Add the given variables to the command environment.
``exit``: integer (optional)
The expected exit code; ``0`` by default.
Example::
title: Shell tests
tests:
- sh: echo Hello, World!
- sh: cat
stdin: |
Hello, World!
- sh: [cat, /etc/shadow]
exit: 1 # Permission denied
Write to File
-------------
This test case creates a file with the given content.
Fields:
``write``: path
The file to create.
``data``: text
The file content.
Example::
write: test/tmp/data.txt
data: |
Hello, World!
Read from File
--------------
The output of this test is the content of a file.
Fields:
``read``: path
The file to read.
Example::
read: test/tmp/data.txt
Remove File
-----------
This test case removes a file. It is not an error if the file does not
exist.
Fields:
``rm``: path or list of paths
File(s) to remove.
Example::
rm: test/tmp/data.txt
Make Directory
--------------
This test case creates a directory.
Parent directories are also created if necessary. It is not an error if
the directory already exists.
Fields:
``mkdir``: path
The directory to create.
Example::
mkdir: test/tmp
Remove Directory
----------------
This test case removes a directory with all its content.
It is not an error if the directory does not exist.
Fields:
``rmdir``: path
The directory to delete.
Example::
rmdir: test/tmp
Doctest
-------
This test case executes ``doctest`` on a set of files.
Fields:
``doctest``: path pattern
Files with doctest sessions.
Example::
doctest: test/test_*.rst
Unittest
--------
This test case executes ``unittest`` test suite.
Fields:
``unittest``: path pattern
Files with unittest tests.
Example::
unittest: test/test_*.py
Pytest
------
This test case executes ``py.test`` test suite.
Package ``pytest`` from http://pytest.org/ must be installed.
Fields:
``pytest``: path pattern
Files with py.test tests.
Example::
pytest: test/test_*.py
Coverage
--------
This test case starts coverage of Python code.
Package ``coverage`` from http://nedbatchelder.com/code/coverage/ must
be installed.
Fields:
``coverage``: file name or ``None``
Path to the configuration file.
``data_file``: file name
Where to save coverage data.
``timid``: ``false`` or ``true`` (optional)
Use a simpler trace function.
``branch``: ``false`` or ``true`` (optional)
Enable branch coverage.
``source``: file paths of package names (optional)
Source files or packages to measure.
``include``: file patterns
Files to measure.
``omit``: file patterns
Files to omit.
Example::
coverage:
source: pbbt
branch: true
Coverage check
--------------
This test case stops coverage and reports measurement summary.
Fields:
``coverage-check``: float
Expected coverage percentage.
Example::
coverage-check: 99.0
Coverage report
---------------
This test case stops coverage and saves coverage report to a file.
Fields:
``coverage-report``: directory
Where to save the report.
Example::
coverage-report: coverage
Custom Test Types
=================
In this section, we discuss how to add custom test types to PBBT.
Suppose we want to test a SQL database by running a series of SQL
queries and validating that we get expected output. To implement this
testing scheme, we need a way to:
* open a connection to the database;
* execute a SQL statement and produce a sequence of records.
The input file may look like this::
title: Database tests
tests:
# Remove the database file left after the last testing session.
- rm: test.sqlite
# Create a new SQLite database.
- connect: test.sqlite
# Run a series of SQL commands.
- sql: |
SELECT 'Hello, World!';
- sql: |
CREATE TABLE student (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
gender CHAR(1) NOT NULL
CHECK (gender in ('f', 'i', 'm')),
dob DATE NOT NULL
);
- sql: |
INSERT INTO student (id, name, gender, dob)
VALUES (1001, 'Linda Wright', 'f', '1988-10-03'),
(1002, 'Beth Thompson', 'f', '1988-01-24'),
(1003, 'Mark Melton', 'm', '1984-06-05'),
(1004, 'Judy Flynn', 'f', '1986-09-02'),
(1005, 'Jonathan Bouchard', 'm', '1982-02-12');
- sql: |
SELECT *
FROM student
ORDER BY dob;
- sql: |
SELECT name
FROM student
WHERE id = 1003;
In this input file, we use two new types of test cases:
``connect``
Specifies the connection to a SQLite database.
``sql``
Specifies a SQL statement to execute.
We will write a PBBT extension implementing these test types.
Create a file ``sql.py`` with the following content::
from pbbt import Test, Field, BaseCase, MatchCase, listof
import sqlite3, traceback, csv, StringIO
@Test
class ConnectCase(BaseCase):
class Input:
connect = Field(str)
def check(self):
self.state['connect'] = None
try:
self.state['connect'] = sqlite3.connect(self.input.connect)
except:
self.ui.literal(traceback.format_exc())
self.ui.warning("exception occurred while"
" connecting to the database")
self.ctl.failed()
else:
self.ctl.passed()
@Test
class SQLCase(MatchCase):
class Input:
sql = Field(str)
class Output:
sql = Field(str)
rows = Field(listof(listof(object)))
def render(self, output):
stream = StringIO.StringIO()
writer = csv.writer(stream, lineterminator='\n')
writer.writerows(output.rows)
return stream.getvalue()
def run(self):
connection = self.state.get('connect')
if not connection:
self.ui.warning("database connection is not defined")
return
rows = []
try:
cursor = connection.cursor()
cursor.execute(self.input.sql)
for row in cursor.fetchall():
rows.append(list(row))
except:
self.ui.literal(traceback.format_exc())
self.ui.warning("exception occurred while"
" executing a SQL query")
connection.rollback()
new_output = None
else:
connection.commit()
new_output = self.Output(sql=self.input.sql, rows=rows)
return new_output
To use this extension, add parameter ``-E sql.py`` to all PBBT
invocations. For example::
$ pbbt -E sql.py input.yaml output.yaml --train
Now we will explain the content of ``sql.py`` line by line.
The first line imports some classes and decorators we will use::
from pbbt import Test, Field, BaseCase, MatchCase
To register a test type, use ``@Test`` decorator. Here is a most
general template::
@Test
class CustomCase(object):
class Input:
some_field = Field(...)
[...]
class Output:
some_field = Field(...)
[...]
def __init__(self, ctl, input, output):
self.ctl = ctl
self.input = input
self.output = output
def __call__(self):
[...]
return new_output
The argument of the decorator must be a class that adheres the following
rules:
* The structure of input and output records is described with nested
classes ``Input`` and ``Output``. Record fields are specified using
``Field`` descriptor.
* To create a test case, the test harness makes an instance of the class.
The class constructor accepts three arguments:
``ctl``
Test harness controller. It is used for user interaction,
reporting test success or failure, and as a storage for
conditional variables.
``input``
The input record.
``output``
The expected output record or ``None``.
* The test case is executed by calling its ``__call__()`` method. This
method must run the test case, generate a new output record, and compare
it with the given expected output record.
If the expected and actual output record do not coincide:
* In the *check* mode, the method must report a failure.
* In the *train* mode, the method may ask the user for permission to
update expected output. If expected output is to be updated, the
method should return the new output record.
PBBT also provides two mixin classes: ``BaseCase`` and ``MatchCase``.
These classes implement most of the necessary functionality for common
types of tests.
Let's review ``connect`` test type, which is implemented by
``ConnectCase`` class::
@Test
class ConnectCase(BaseCase):
class Input:
connect = Field(str)
def check(self):
[...]
``ConnectCase`` is inherited from ``BaseCase``, which is suitable for
test which produce no output data and are executed for their side
effects. The nested ``Input`` class definition is used to declare the
fields of the input record. In this case, the input record has just one
text field ``connect``, which contains the name of the database.
Test types inherited from ``BaseCase`` must override abstract method
``check()``::
import sqlite3, traceback
[...]
@Test
class ConnectCase(BaseCase):
[...]
def check(self):
self.state['connect'] = None
try:
self.state['connect'] = sqlite3.connect(self.input.connect)
except:
self.ui.literal(traceback.format_exc())
self.ui.warning("exception occurred while"
" connecting to the database")
self.ctl.failed()
else:
self.ctl.passed()
This code attempts to create a new database connection and store it as a
conditional variable ``connect``. If the attempt fails, it calls
``ui.literal()`` to display the exception traceback and ``ctl.failed()``
to report test failure. Otherwise, ``ctl.passed()`` is called to
indicate that the test succeeded.
Next, let's review ``sql`` test type::
@Test
class SQLCase(MatchCase):
class Input:
sql = Field(str)
class Output:
sql = Field(str)
rows = Field(listof(listof(object)))
def run(self):
[...]
def render(self, output):
[...]
This test type has both input and output records, which are described
with ``Input`` and ``Output`` nested classes. The input record contains
one field ``sql``, a SQL query to execute. The output record contains
two fields: ``sql`` and ``rows``. Field ``sql`` contains the same SQL
query and is used for matching the output record with the complementary
input record. Field ``rows`` contains a list of output rows generated
by the SQL query.
``SQLCase`` is inherited from ``MatchCase``, which is a mixin class
for test types that produce text output. Test types inherited from
``MatchCase`` must override two methods:
``run()``
Executes the test case and returns the produced output record.
``render(output)``
Convert an output record to printable form.
In ``SQLCase``, ``render()`` is implemented by converting output rows to
CSV format::
import csv, StringIO
[...]
@Test
class SQLCase(MatchCase):
[...]
def render(self, output):
stream = StringIO.StringIO()
writer = csv.writer(stream, lineterminator='\n')
writer.writerows(output.rows)
return stream.getvalue()
Method ``run()`` is implemented as follows::
@Test
class SQLCase(MatchCase):
[...]
def run(self):
connection = self.state.get('connect')
if not connection:
self.ui.warning("database connection is not defined")
return
rows = []
try:
cursor = connection.cursor()
cursor.execute(self.input.sql)
for row in cursor.fetchall():
rows.append(list(row))
except:
self.ui.literal(traceback.format_exc())
self.ui.warning("exception occurred while"
" executing a SQL query")
connection.rollback()
new_output = None
else:
connection.commit()
new_output = self.Output(sql=self.input.sql, rows=rows)
return new_output
Command-line Interface
======================
Usage::
pbbt [<options>] INPUT [OUTPUT]
Here, ``INPUT`` and ``OUTPUT`` are files which contain input and output
test data respectively.
The following options are available:
``-h``, ``--help``
Display usage information and exit.
``-q``, ``--quiet``
Show only warnings and errors.
``-T``, ``--train``
Run tests in the training mode.
``-P``, ``--purge``
Purge stale output data.
``-M N``, ``--max-errors N``
Halt after ``N`` tests failed; ``0`` means "never".
``-D VAR``, ``-D VAR=VALUE``, ``--define VAR``, ``--define VAR=VALUE``
Set a conditional variable.
``-E FILE``, ``-E MODULE``, ``--extend FILE``, ``--extend MODULE``
Load a PBBT extension from a file or a Python module.
``-S ID``, ``--suite ID``
Run a specific test suite.
PBBT can also read configuration from the following files:
``setup.cfg``
This file is in INI format with PBBT settings defined in section
``[pbbt]``. The following parameters are recognized: ``extend``,
``input``, ``output``, ``define``, ``suite``, ``train``, ``purge``,
``max_errors``, ``quiet``.
``pbbt.yaml``
This file must be a YAML file with the following keys: ``extend``,
``input``, ``output``, ``define``, ``suite``, ``train``, ``purge``,
``max-errors``, ``quiet``.
PBBT can also be executed as a Distutils command::
python setup.py pbbt
In this case, PBBT configuration could be specified in ``setup.cfg``
or via command-line parameters.
API Reference
=============
``pbbt.maybe(T)``
Pseudo-type for ``isinstance(X, ...)``: checks if ``X`` is an
instance of ``T`` or equal to ``None``.
``pbbt.oneof(T1, T2, ...)``
Pseudo-type for ``isinstance(X, ...)``: checks if ``X`` is an
instance of ``T1`` or an instance of ``T2``, etc.
``pbbt.choiceof(values)``
Pseudo-type for ``isinstance(X, ...)``: checks if ``X`` is equal to
one of the given values.
``pbbt.listof(T, length=None)``
Pseudo-type for ``isinstance(X, ...)``: checks if ``X`` is a list of
elements of ``T``.
``pbbt.tupleof(T1, T2, ...)``
Pseudo-type for ``isinstance(X, ...)``: checks if ``X`` is a tuple
with fields of types ``T1``, ``T2``, etc.
``pbbt.dictof(T1, T2)``
Pseudo-type for ``isinstance(X, ...)``: checks if ``X`` is a
dictionary with keys of type ``T1`` and values of type ``T2``.
``pbbt.raises(E)``
Use with ``with`` clause to verify that the nested block raises an
exception of the given type.
``pbbt.raises(E, fn, *args, **kwds)``
Verifies that the function call ``fn(*args, **kwds)`` raises an
exception of the given type.
``pbbt.Test(CaseType)``
Registers the given class as a test type.
``pbbt.Field(check=None, default=REQUIRED, order=None, hint=None)``
Describes a field of an input or an output record.
``check``
The type of the field value.
``default``
Default value if the field is missing. If not set, the