summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test/regrtest.py
blob: 17e7f4ef79df06d4756c7aede1300be2bf6f6cd2 (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
37
38
"""Run Python's standard test suite using importlib.__import__.

Tests known to fail because of assumptions that importlib (properly)
invalidates are automatically skipped if the entire test suite is run.
Otherwise all command-line options valid for test.regrtest are also valid for
this script.

XXX FAILING
    test_builtin  # Wanting a TypeError for an integer name
    test_import  # execution bit, exception name differing, file name differing
                    between code and module (?)
    test_importhooks  # package not set in _gcd_import() but level > 0
    test_pep3120  # Difference in exception
    test_runpy  # Importing sys.imp.eric raises AttributeError instead of
                    ImportError (as does any attempt to import a sub-module
                    from a non-package, e.g. tokenize.menotreal)

"""
import importlib
import sys
from test import regrtest

if __name__ == '__main__':
    __builtins__.__import__ = importlib.__import__

    exclude = ['--exclude',
                'test_frozen', # Does not expect __loader__ attribute
                'test_pkg',  # Does not expect __loader__ attribute
                'test_pydoc', # Does not expect __loader__ attribute
              ]

    # Switching on --exclude implies running all test but the ones listed, so
    # only use it when one is not running an explicit test
    if len(sys.argv) == 1:
        # No programmatic way to specify tests to exclude
        sys.argv.extend(exclude)

    regrtest.main(quiet=True)