forked from neomonkeus/pyffi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rundoctest.py
115 lines (104 loc) · 4.36 KB
/
rundoctest.py
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
import doctest
import logging
import sys
import unittest
import pyffi
import pyffi.object_models.common
import pyffi.object_models
import pyffi.object_models.xml
import pyffi.object_models.mex
import pyffi.object_models.any_type
import pyffi.object_models.simple_type
import pyffi.object_models.array_type
import pyffi.object_models.binary_type
import pyffi.object_models.xml.basic
import pyffi.object_models.xml.bit_struct
import pyffi.object_models.xml.enum
import pyffi.object_models.xml.expression
import pyffi.object_models.xml.struct_
import pyffi.utils
import pyffi.utils.tristrip
import pyffi.utils.vertex_cache
import pyffi.utils.mathutils
import pyffi.utils.quickhull
import pyffi.utils.inertia
import pyffi.utils.tangentspace
import pyffi.utils.mopp
import pyffi.formats.nif
import pyffi.formats.cgf
import pyffi.formats.kfm
import pyffi.formats.dds
import pyffi.formats.tga
import pyffi.formats.egm
import pyffi.formats.esp
import pyffi.formats.tri
import pyffi.formats.bsa
import pyffi.formats.egt
import pyffi.formats.psk
import pyffi.formats.rockstar.dir_
import pyffi.spells
import pyffi.spells.nif
import pyffi.spells.nif.fix
import pyffi.spells.nif.modify
import pyffi.spells.nif.check
import pyffi.spells.nif.dump
# these two do not yet work on py3k
if sys.version_info[0] < 3:
import pyffi.object_models.xsd
import pyffi.formats.dae
# force number of jobs to be 1 (multithreading makes doctesting difficult)
pyffi.spells.Toaster.DEFAULT_OPTIONS["jobs"] = 1
mods = [val for (key, val) in sys.modules.items()
if key.startswith('pyffi')]
suite = unittest.TestSuite()
for mod in mods:
try:
suite.addTest(doctest.DocTestSuite(mod))
except ValueError: # no tests
pass
# various regression tests (outside documentation)
suite.addTest(doctest.DocFileSuite('tests/nif/niftoaster.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/optimize.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/dump_tex.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/ffvt3rskin.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/fix_texturepath.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/fix_tangentspace.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/fix_tangentspace_series_parallel.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/fix_detachhavoktristripsdata.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/fix_clampmaterialalpha.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/opt_mergeduplicates.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/modify_delbranches.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/modify_delvertexcolor.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/fix_cleanstringpalette.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/modify_substitutestringpalette.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/modify_allbonepriorities.txt'))
suite.addTest(doctest.DocFileSuite('tests/om_simpletype.txt'))
suite.addTest(doctest.DocFileSuite('tests/om_arraytype.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/matrix.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/skinpartition.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/bhkpackednitristripsshape.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/opt_delunusedbones.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/opt_delzeroscale.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/opt_collisiongeometry.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/opt_collision_to_box_shape.txt'))
suite.addTest(doctest.DocFileSuite('tests/nif/opt_vertex_cache.txt'))
suite.addTest(doctest.DocFileSuite('tests/cgf/cgftoaster.txt'))
suite.addTest(doctest.DocFileSuite('tests/kfm/kfmtoaster.txt'))
suite.addTest(doctest.DocFileSuite('docs-sphinx/intro.rst'))
# TODO: examples
#suite.addTest(doctest.DocFileSuite('examples/*.txt'))
# set up logger
# this is a hack for StreamHandler to make it work with doctest
# see http://mail.python.org/pipermail/python-list/2007-January/423842.html
class WrapStdOut(object):
def __getattr__(self, name):
return getattr(sys.stdout, name)
logger = logging.getLogger("pyffi")
logger.setLevel(logging.INFO) # skip debug messages
loghandler = logging.StreamHandler(WrapStdOut())
loghandler.setLevel(logging.DEBUG)
logformatter = logging.Formatter("%(name)s:%(levelname)s:%(message)s")
loghandler.setFormatter(logformatter)
logger.addHandler(loghandler)
# run tests
unittest.TextTestRunner(verbosity=10).run(suite)