aboutsummaryrefslogtreecommitdiff
blob: de105158fc66cc89eeeee97f430da7675b0109c4 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import sys
import importlib
import pytest

# This is a workaround for a dubious feature of CPython's test suite: it skips
# tests silently if importing a module fails.  This makes some partial sense
# for CPython itself when testing C extension modules directly, because very
# often (but not always) a C extension module is either completely absent or
# imports successfully.  But for PyPy it's a mess because it can hide mistakes
# very easily, and it did.  So the list we build here should contain the names
# of every module that CPython's tests import with test.support.import_module()
# but that should really be present on the running platform.


expected_modules = []

# ----- everywhere -----
expected_modules += [
    'MimeWriter',
    'bz2',
    'commands',
    'compiler',
    '_ctypes',
    'dircache',
    'fpformat',
    'gzip',
    'htmllib',
    'mhlib',
    'mimetools',
    'mmap',
    'multifile',
    '_multiprocessing',
    'multiprocessing.synchronize',
    'mutex',
    'new',
    'sre',
    'rfc822',
    'sets',
    '_sqlite3',
    'ssl',
    'thread',
    'threading',
    'xmllib',
    'zlib',
]

# ----- non-Windows -----
if sys.platform != 'win32':
    expected_modules += [
        'curses',
        'curses.ascii',
        'curses.textpad',
        'dbm',
        'fcntl',
        'gdbm',
        'grp',
        'posix',
        'pwd',
        'readline',
        'resource',
        'termios',
    ]
else:
    # ----- Windows only -----
    expected_modules += [
        '_winreg',
    ]

# ----- Linux only -----
if sys.platform.startswith('linux'):
    expected_modules += [
        'crypt',
    ]


# ------------------------------------------------

@pytest.fixture(scope="module", params=expected_modules)
def modname(request):
    return request.param

def test_expected_modules(modname):
    importlib.import_module(modname)