Skip to content

Commit 8f6eae2

Browse files
committed
Merge remote-tracking branch 'origin/master' into wsgi-middleware
2 parents 2b574c0 + c14dfcc commit 8f6eae2

File tree

6 files changed

+38
-1
lines changed

6 files changed

+38
-1
lines changed

tests/integrations/django/myapp/management/__init__.py

Whitespace-only changes.

tests/integrations/django/myapp/management/commands/__init__.py

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from django.core.management.base import BaseCommand
2+
3+
4+
class Command(BaseCommand):
5+
def add_arguments(self, parser):
6+
pass
7+
8+
def handle(self, *args, **options):
9+
1 / 0

tests/integrations/django/myapp/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"django.contrib.sessions",
4949
"django.contrib.messages",
5050
"django.contrib.staticfiles",
51+
"tests.integrations.django.myapp",
5152
]
5253

5354

tests/integrations/django/test_basic.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
django = pytest.importorskip("django")
44

55

6-
from tests.integrations.django.myapp.wsgi import application
76
from werkzeug.test import Client
7+
from django.core.management import execute_from_command_line
8+
89

910
try:
1011
from django.urls import reverse
@@ -13,6 +14,8 @@
1314

1415
from sentry_sdk import Hub
1516

17+
from tests.integrations.django.myapp.wsgi import application
18+
1619

1720
@pytest.fixture
1821
def client(monkeypatch_test_transport):
@@ -72,3 +75,11 @@ def test_user_captured(client, capture_events):
7275
def test_404(client):
7376
content, status, headers = client.get("/404")
7477
assert status.lower() == "404 not found"
78+
79+
80+
def test_management_command_raises():
81+
# This just checks for our assumption that Django passes through all
82+
# exceptions by default, so our excepthook can be used for management
83+
# commands.
84+
with pytest.raises(ZeroDivisionError):
85+
execute_from_command_line(["manage.py", "mycrash"])

tests/integrations/flask/test_flask.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,19 @@ def index():
324324
def test_no_errors_without_request(app):
325325
with app.app_context():
326326
capture_exception(ValueError())
327+
328+
329+
def test_cli_commands_raise(app):
330+
if not hasattr(app, "cli"):
331+
pytest.skip("Too old flask version")
332+
333+
from flask.cli import ScriptInfo
334+
335+
@app.cli.command()
336+
def foo():
337+
1 / 0
338+
339+
with pytest.raises(ZeroDivisionError):
340+
app.cli.main(
341+
args=["foo"], prog_name="myapp", obj=ScriptInfo(create_app=lambda _: app)
342+
)

0 commit comments

Comments
 (0)