-
Notifications
You must be signed in to change notification settings - Fork 19
/
runtests.py
71 lines (58 loc) · 2.04 KB
/
runtests.py
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
#!/usr/bin/env python
import argparse
import os
import sys
import warnings
from django.core.management import execute_from_command_line
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"
def parse_args(args=None):
parser = argparse.ArgumentParser()
parser.add_argument(
"--deprecation",
choices=["all", "pending", "imminent", "none"],
default="imminent",
)
return parser.parse_known_args(args)
def runtests():
args, rest = parse_args()
only_wagtail = r"^wagtail(\.|$)"
only_wagtail_headless_preview = r"^wagtail_headless_preview(\.|$)"
if args.deprecation == "all":
# Show all deprecation warnings from all packages
warnings.simplefilter("default", DeprecationWarning)
warnings.simplefilter("default", PendingDeprecationWarning)
elif args.deprecation == "pending":
# Show all deprecation warnings from Wagtail
warnings.filterwarnings(
"default", category=DeprecationWarning, module=only_wagtail
)
warnings.filterwarnings(
"default", category=PendingDeprecationWarning, module=only_wagtail
)
# and all from wagtail_headless_preview
warnings.filterwarnings(
"default", category=DeprecationWarning, module=only_wagtail_headless_preview
)
warnings.filterwarnings(
"default",
category=PendingDeprecationWarning,
module=only_wagtail_headless_preview,
)
elif args.deprecation == "imminent":
# Show only imminent deprecation warnings
warnings.filterwarnings(
"default", category=DeprecationWarning, module=only_wagtail
)
warnings.filterwarnings(
"default", category=DeprecationWarning, module=only_wagtail_headless_preview
)
elif args.deprecation == "none":
# Deprecation warnings are ignored by default
pass
argv = [sys.argv[0]] + rest
try:
execute_from_command_line(argv)
finally:
pass
if __name__ == "__main__":
runtests()