Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Reformat whole codebase with black #5310

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
47 changes: 30 additions & 17 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,62 @@


def pytest_addoption(parser):
parser.addoption('--deprecation', choices=['all', 'pending', 'imminent', 'none'], default='pending')
parser.addoption('--postgres', action='store_true')
parser.addoption('--elasticsearch', action='store_true')
parser.addoption(
"--deprecation",
choices=["all", "pending", "imminent", "none"],
default="pending",
)
parser.addoption("--postgres", action="store_true")
parser.addoption("--elasticsearch", action="store_true")


def pytest_configure(config):
deprecation = config.getoption('deprecation')
deprecation = config.getoption("deprecation")

only_wagtail = r'^wagtail(\.|$)'
if deprecation == 'all':
only_wagtail = r"^wagtail(\.|$)"
if deprecation == "all":
# Show all deprecation warnings from all packages
warnings.simplefilter('default', DeprecationWarning)
warnings.simplefilter('default', PendingDeprecationWarning)
elif deprecation == 'pending':
warnings.simplefilter("default", DeprecationWarning)
warnings.simplefilter("default", PendingDeprecationWarning)
elif 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 deprecation == 'imminent':
warnings.filterwarnings(
"default", category=DeprecationWarning, module=only_wagtail
)
warnings.filterwarnings(
"default", category=PendingDeprecationWarning, module=only_wagtail
)
elif deprecation == "imminent":
# Show only imminent deprecation warnings from wagtail
warnings.filterwarnings('default', category=DeprecationWarning, module=only_wagtail)
elif deprecation == 'none':
warnings.filterwarnings(
"default", category=DeprecationWarning, module=only_wagtail
)
elif deprecation == "none":
# Deprecation warnings are ignored by default
pass

if config.getoption('postgres'):
os.environ['DATABASE_ENGINE'] = 'django.db.backends.postgresql'
if config.getoption("postgres"):
os.environ["DATABASE_ENGINE"] = "django.db.backends.postgresql"

# Setup django after processing the pytest arguments so that the env
# variables are available in the settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wagtail.tests.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "wagtail.tests.settings")
django.setup()

# Activate a language: This affects HTTP header HTTP_ACCEPT_LANGUAGE sent by
# the Django test client.
from django.utils import translation

translation.activate("en")

from wagtail.tests.settings import MEDIA_ROOT, STATIC_ROOT

shutil.rmtree(STATIC_ROOT, ignore_errors=True)
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)


def pytest_unconfigure(config):
from wagtail.tests.settings import MEDIA_ROOT, STATIC_ROOT

shutil.rmtree(STATIC_ROOT, ignore_errors=True)
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)
Loading