-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
101 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
import os | ||
import shutil | ||
import sys | ||
import warnings | ||
|
||
from django.core.management import execute_from_command_line | ||
|
||
|
||
os.environ["DJANGO_SETTINGS_MODULE"] = "wagtailinventory.tests.settings" | ||
|
||
|
||
def make_parser(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--deprecation", | ||
choices=["all", "pending", "imminent", "none"], | ||
default="imminent", | ||
) | ||
return parser | ||
|
||
|
||
def parse_args(args=None): | ||
return make_parser().parse_known_args(args) | ||
|
||
|
||
def runtests(): | ||
args, rest = parse_args() | ||
|
||
only_wagtail = r"^wagtail(\.|$)" | ||
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 | ||
) | ||
elif args.deprecation == "imminent": | ||
# Show only imminent deprecation warnings from wagtail | ||
warnings.filterwarnings( | ||
"default", category=DeprecationWarning, module=only_wagtail | ||
) | ||
elif args.deprecation == "none": | ||
# Deprecation warnings are ignored by default | ||
pass | ||
|
||
argv = [sys.argv[0]] + rest | ||
|
||
try: | ||
execute_from_command_line(argv) | ||
finally: | ||
from wagtail.tests.settings import MEDIA_ROOT, STATIC_ROOT | ||
|
||
shutil.rmtree(STATIC_ROOT, ignore_errors=True) | ||
shutil.rmtree(MEDIA_ROOT, ignore_errors=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
runtests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters