Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.core.management.base import BaseCommand


class Command(BaseCommand):
def add_arguments(self, parser):
pass

def handle(self, *args, **options):
1 / 0
1 change: 1 addition & 0 deletions tests/integrations/django/myapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"tests.integrations.django.myapp",
]


Expand Down
9 changes: 9 additions & 0 deletions tests/integrations/django/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


from django.test import Client
from django.core.management import execute_from_command_line

try:
from django.urls import reverse
Expand Down Expand Up @@ -79,3 +80,11 @@ def test_user_captured(client, capture_events):
def test_404(client):
response = client.get("/404")
assert response.status_code == 404


def test_management_command_raises():
# This just checks for our assumption that Django passes through all
# exceptions by default, so our excepthook can be used for management
# commands.
with pytest.raises(ZeroDivisionError):
execute_from_command_line(["manage.py", "mycrash"])
16 changes: 16 additions & 0 deletions tests/integrations/flask/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,19 @@ def index():
def test_no_errors_without_request(app):
with app.app_context():
capture_exception(ValueError())


def test_cli_commands_raise(app):
if not hasattr(app, "cli"):
pytest.skip("Too old flask version")

from flask.cli import ScriptInfo

@app.cli.command()
def foo():
1 / 0

with pytest.raises(ZeroDivisionError):
app.cli.main(
args=["foo"], prog_name="myapp", obj=ScriptInfo(create_app=lambda _: app)
)