1
# ------------------------------------------------------------------------------
2
#
3
#  Copyright (c) 2005-2013, Enthought, Inc.
4
#  All rights reserved.
5
#
6
#  This software is provided without warranty under the terms of the BSD
7
#  license included in LICENSE.txt and may be redistributed only
8
#  under the conditions described in the aforementioned license.  The license
9
#  is also available online at http://www.enthought.com/licenses/BSD.txt
10
#
11
#  Thanks for using Enthought open source!
12
#
13
#  Author: David C. Morrill
14
#  Date:   10/07/2004
15
#
16
# ------------------------------------------------------------------------------
17

18

19 11
try:
20 11
    from traitsui._version import full_version as __version__
21 0
except ImportError:
22 0
    __version__ = "not-built"
23

24 11
__requires__ = ["traits", "pyface>=6.0.0"]
25 11
__extras_require__ = {
26
    "wx": ["wxpython>=4", "numpy"],
27
    "pyqt": ["pyqt>=4.10", "pygments"],
28
    "pyqt5": ["pyqt5", "pygments"],
29
    "pyside2": ["pyside2", "shiboken2", "pygments"],
30
    "demo": [
31
        # to be deprecated, see enthought/traitsui#950
32
        "configobj", "docutils",
33
    ],
34
    "examples": [
35
        # Dependencies for examples
36
        "apptools",
37
        "chaco",   # for a very simple example, see enthought/traitsui#1139
38
        "h5py",
39
        "numpy",
40
        "pandas",
41
        "tables",
42
    ],
43
    "editors": [
44
        # Optional dependencies for certain editors which may not be needed by
45
        # projects. If they are absent, ``traitsui.api``` should still be
46
        # importable and the relevant tests should be skipped.
47
        "numpy",   # For ArrayEditor and DataFrameEditor
48
        "pandas",  # For DataFrameEditor
49
    ],
50
    "test": [
51
        # Dependencies for running test suites.
52
        "packaging",
53
    ],
54
}
55

56

57
# ============================= Test Loader ==================================
58 11
def load_tests(loader, standard_tests, pattern):
59
    """ Custom test loading function that enables test filtering using regex
60
    exclusion pattern.
61

62
    Parameters
63
    ----------
64
    loader : unittest.TestLoader
65
        The instance of test loader
66
    standard_tests : unittest.TestSuite
67
        Tests that would be loaded by default from this module (no tests)
68
    pattern : str
69
        An inclusion pattern used to match test files (test*.py default)
70

71
    Returns
72
    -------
73
    filtered_package_tests : unittest.TestSuite
74
        TestSuite representing all package tests that did not match specified
75
        exclusion pattern.
76
    """
77 11
    from os import environ
78 11
    from os.path import dirname
79 11
    from traitsui.tests._tools import filter_tests
80 11
    from unittest import TestSuite
81

82
    # Make sure the right toolkit is up and running before importing tests
83 11
    from traitsui.toolkit import toolkit
84 11
    toolkit()
85

86 11
    this_dir = dirname(__file__)
87 11
    package_tests = loader.discover(start_dir=this_dir, pattern=pattern)
88

89 11
    exclusion_pattern = environ.get("EXCLUDE_TESTS", None)
90 11
    if exclusion_pattern is None:
91 0
        return package_tests
92

93 11
    filtered_package_tests = TestSuite()
94 11
    for test_suite in package_tests:
95 11
        filtered_test_suite = filter_tests(test_suite, exclusion_pattern)
96 11
        filtered_package_tests.addTest(filtered_test_suite)
97

98 11
    return filtered_package_tests

Read our documentation on viewing source code .

Loading