aboutsummaryrefslogtreecommitdiff
path: root/dev/tests.py
blob: 553e27f12abba1c4363b096f729b4774413644b4 (plain)
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
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function

import unittest
import re

from tests.test_cms import CMSTests
from tests.test_crl import CRLTests
from tests.test_csr import CSRTests
from tests.test_keys import KeysTests
from tests.test_ocsp import OCSPTests
from tests.test_pem import PEMTests
from tests.test_tsp import TSPTests
from tests.test_x509 import X509Tests
from tests.test_core import CoreTests


test_classes = [CMSTests, CRLTests, CSRTests, KeysTests, OCSPTests, PEMTests, TSPTests, X509Tests, CoreTests]


def run(matcher=None):
    suite = unittest.TestSuite()
    loader = unittest.TestLoader()
    for test_class in test_classes:
        if matcher:
            names = loader.getTestCaseNames(test_class)
            for name in names:
                if re.search(matcher, name):
                    suite.addTest(test_class(name))
        else:
            suite.addTest(loader.loadTestsFromTestCase(test_class))
    verbosity = 2 if matcher else 1
    unittest.TextTestRunner(verbosity=verbosity).run(suite)