Debian Codegraph @

extra_tests/test_pypy_modules.py

raw symbols SCIP
1 import sys
2 import importlib
3 import pytest
4
5 # This is a workaround for a dubious feature of CPython's test suite: it skips
6 # tests silently if importing a module fails. This makes some partial sense
7 # for CPython itself when testing C extension modules directly, because very
8 # often (but not always) a C extension module is either completely absent or
9 # imports successfully. But for PyPy it's a mess because it can hide mistakes
10 # very easily, and it did. So the list we build here should contain the names
11 # of every module that CPython's tests import with test.support.import_module()
12 # but that should really be present on the running platform.
13
14
15 expected_modules = []
16
17 # ----- everywhere -----
18 expected_modules += [
19 '_opcode',
20 'asyncio',
21 'bz2',
22 'code',
23 'ctypes.test',
24 'gzip',
25 '_hashlib',
26 'lzma',
27 'mmap',
28 '_multiprocessing',
29 'multiprocessing.synchronize',
30 'select',
31 '_sqlite3',
32 'ssl',
33 '_thread',
34 'threading',
35 'zlib',
36 ]
37
38 # ----- non-Windows -----
39 if sys.platform != 'win32':
40 expected_modules += [
41 'curses',
42 'curses.ascii',
43 'curses.textpad',
44 'dbm',
45 'dbm.gnu',
46 'fcntl',
47 'grp',
48 'posix',
49 'pty',
50 'pwd',
51 'resource',
52 'syslog',
53 'termios',
54 ]
55 else:
56 # ----- Windows only -----
57 expected_modules += [
58 'winreg',
59 ]
60
61 # ----- Linux only -----
62 if sys.platform.startswith('linux'):
63 expected_modules += [
64 'crypt',
65 ]
66
67
68 # ------------------------------------------------
69
70 @pytest.fixture(scope="module", params=expected_modules)
71 def modname(request):
72 return request.param
73
74 def test_expected_modules(modname):
75 importlib.import_module(modname)