aboutsummaryrefslogtreecommitdiff
path: root/lnt/tests/__init__.py
blob: b66877675774e010ce533a1d0bdfcc4156d5c65f (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
34
35
36
"""
Access to built-in tests.
"""
# FIXME: There are better ways to do this, no doubt. We also would like this to
# be extensible outside of the installation. Lookup how 'nose' handles this.

_known_tests = set(['compile', 'nt', 'test_suite'])


def get_names():
    """get_test_names() -> list

    Return the list of known built-in test names.
    """
    return _known_tests


def get_module(name):
    import importlib
    """get_test_instance(name) -> lnt.test.BuiltinTest

    Return an instance of the named test.
    """
    # Allow hyphens instead of underscores when specifying the test on the
    # command line. (test-suite instead of test_suite).
    name = name.replace('-', '_')

    if name not in _known_tests:
        raise KeyError(name)

    module_name = "lnt.tests.%s" % name
    module = importlib.import_module(module_name)
    return module


__all__ = ['get_names', 'get_module']