-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Run tests using pytest * Bump Postgres to version 12 Django 4.2 requires Postgres >= 12: https://docs.djangoproject.com/en/4.2/ref/databases/#postgresql-notes * Review comments
- Loading branch information
Showing
7 changed files
with
44 additions
and
59 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
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 |
---|---|---|
@@ -1,66 +1,15 @@ | ||
#!/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"] = "{{ cookiecutter.__project_name_snake }}.test.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.test.settings import MEDIA_ROOT, STATIC_ROOT | ||
|
||
shutil.rmtree(STATIC_ROOT, ignore_errors=True) | ||
shutil.rmtree(MEDIA_ROOT, ignore_errors=True) | ||
def main(): | ||
os.environ["DJANGO_SETTINGS_MODULE"] = "{{ cookiecutter.__project_name_snake }}.test.settings" | ||
execute_from_command_line(sys.argv) | ||
|
||
|
||
if __name__ == "__main__": | ||
runtests() | ||
main() |
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,6 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def temporary_media_dir(settings, tmp_path: pytest.TempdirFactory): | ||
settings.MEDIA_ROOT = tmp_path / "media" |
14 changes: 14 additions & 0 deletions
14
{{ cookiecutter.__project_name_kebab }}/tests/test_placeholder.py
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,14 @@ | ||
""" | ||
Placeholder test, so that pytest doesn't fail with an empty testsuite. Feel free to | ||
remove this when you start writing tests. | ||
https://github.com/pytest-dev/pytest/issues/2393 | ||
""" | ||
|
||
import pytest | ||
|
||
|
||
pytestmark = pytest.mark.django_db | ||
|
||
|
||
def test_homepage(client): | ||
assert client.get("/").status_code == 200 |
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