Skip to content
Myr

test_imports.py

This file

Path

tests/test_imports.py

80 lines · 1.5 KiB · Python

Last changed by

`ParamType` and other typing improvements (#3371)Rowlando13before adoption8a2b489

History of this file

Take it

The walk stopped after 200 commits: lines older than 9ce34f2 point at it.

Make faqs section. Add the first question about windows shell expansion. (#2927)Rowlando13before adoption9ce34f2

lines 1–29why, one step back
1import json
2import subprocess3import sys45from click._compat import WIN67IMPORT_TEST = b"""\8import builtins910found_imports = set()11real_import = builtins.__import__12import sys1314def tracking_import(module, locals=None, globals=None, fromlist=None,15 level=0):16 rv = real_import(module, locals, globals, fromlist, level)17 if globals and globals['__name__'].startswith('click') and level == 0:18 found_imports.add(module)19 return rv20builtins.__import__ = tracking_import2122import click23rv = list(found_imports)24import json25click.echo(json.dumps(rv))26"""2728ALLOWED_IMPORTS = {29 "__future__",

`ParamType` and other typing improvements (#3371)Rowlando13before adoption8a2b489

line 30why, one step back
30 "abc",

Fix reconciliation of envvar with `default`, `flag_value` and `type` parameters for flag options (#2956)Kevin Deldyckebefore adoption565f36d

line 31why, one step back
31 "codecs",

Make faqs section. Add the first question about windows shell expansion. (#2927)Rowlando13before adoption9ce34f2

lines 32–33why, one step back
32 "collections",
33 "collections.abc",

Fix reconciliation of envvar with `default`, `flag_value` and `type` parameters for flag options (#2956)Kevin Deldyckebefore adoption565f36d

line 34why, one step back
34 "configparser",

Make faqs section. Add the first question about windows shell expansion. (#2927)Rowlando13before adoption9ce34f2

line 35why, one step back
35 "contextlib",

Fix reconciliation of envvar with `default`, `flag_value` and `type` parameters for flag options (#2956)Kevin Deldyckebefore adoption565f36d

lines 36–39why, one step back
36 "datetime",
37 "enum",38 "errno",39 "fcntl",

Make faqs section. Add the first question about windows shell expansion. (#2927)Rowlando13before adoption9ce34f2

line 40why, one step back
40 "functools",

Fix reconciliation of envvar with `default`, `flag_value` and `type` parameters for flag options (#2956)Kevin Deldyckebefore adoption565f36d

line 41why, one step back
41 "gettext",

Make faqs section. Add the first question about windows shell expansion. (#2927)Rowlando13before adoption9ce34f2

lines 42–43why, one step back
42 "inspect",
43 "io",

Fix reconciliation of envvar with `default`, `flag_value` and `type` parameters for flag options (#2956)Kevin Deldyckebefore adoption565f36d

lines 44–49why, one step back
44 "itertools",
45 "os",46 "re",47 "stat",48 "struct",49 "sys",

Make faqs section. Add the first question about windows shell expansion. (#2927)Rowlando13before adoption9ce34f2

lines 50–51why, one step back
50 "threading",
51 "types",

Fix reconciliation of envvar with `default`, `flag_value` and `type` parameters for flag options (#2956)Kevin Deldyckebefore adoption565f36d

line 52why, one step back
52 "typing",

`ParamType` and other typing improvements (#3371)Rowlando13before adoption8a2b489

line 53why, one step back
53 "uuid",

Fix reconciliation of envvar with `default`, `flag_value` and `type` parameters for flag options (#2956)Kevin Deldyckebefore adoption565f36d

line 54why, one step back
54 "weakref",

Make faqs section. Add the first question about windows shell expansion. (#2927)Rowlando13before adoption9ce34f2

lines 55–57why, one step back
55}
5657if WIN:

fix windows import checkDavid Lordbefore adoptionfeffea5

lines 58–66why, one step back
58 ALLOWED_IMPORTS.update(
59 {60 "ctypes",61 "ctypes._layout",62 "ctypes.wintypes",63 "msvcrt",64 "time",65 }66 )

Make faqs section. Add the first question about windows shell expansion. (#2927)Rowlando13before adoption9ce34f2

lines 67–80why, one step back
67
6869def test_light_imports():70 c = subprocess.Popen(71 [sys.executable, "-"], stdin=subprocess.PIPE, stdout=subprocess.PIPE72 )73 rv = c.communicate(IMPORT_TEST)[0]74 rv = rv.decode("utf-8")75 imported = json.loads(rv)7677 for module in imported:78 if module == "click" or module.startswith("click."):79 continue80 assert module in ALLOWED_IMPORTS