4 class TestAppliance(unittest
.TestCase
):
9 for filename
in os
.listdir(DATA
):
10 if os
.path
.isfile(os
.path
.join(DATA
, filename
)):
11 root
, ext
= os
.path
.splitext(filename
)
12 tests
.setdefault(root
, []).append(ext
)
14 def add_tests(cls
, method_name
, *extensions
):
15 for test
in cls
.tests
:
16 available_extensions
= cls
.tests
[test
]
17 for ext
in extensions
:
18 if ext
not in available_extensions
:
21 filenames
= [os
.path
.join(cls
.DATA
, test
+ext
) for ext
in extensions
]
22 def test_method(self
, test
=test
, filenames
=filenames
):
23 getattr(self
, '_'+method_name
)(test
, *filenames
)
24 test
= test
.replace('-', '_')
25 test_method
.__name
__ = '%s_%s' % (method_name
, test
)
26 setattr(cls
, test_method
.__name
__, test_method
)
27 add_tests
= classmethod(add_tests
)