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

docs: Added debug=True in Testing to display exception stack trace #3860

Merged
merged 3 commits into from
Nov 17, 2024
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
2 changes: 1 addition & 1 deletion docs/examples/testing/test_get_session_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def set_session_data(request: Request) -> None:
request.session["foo"] = "bar"


app = Litestar(route_handlers=[set_session_data], middleware=[session_config.middleware])
app = Litestar(route_handlers=[set_session_data], middleware=[session_config.middleware], debug=True)

with TestClient(app=app, session_config=session_config) as client:
client.post("/test").json()
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/testing/test_get_session_data_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def set_session_data(request: Request) -> None:
request.session["foo"] = "bar"


app = Litestar(route_handlers=[set_session_data], middleware=[session_config.middleware])
app = Litestar(route_handlers=[set_session_data], middleware=[session_config.middleware], debug=True)


async def test_set_session_data() -> None:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/testing/test_health_check_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def health_check() -> str:
return "healthy"


app = Litestar(route_handlers=[health_check])
app = Litestar(route_handlers=[health_check], debug=True)


@pytest.fixture(scope="function")
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/testing/test_health_check_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def health_check() -> str:
return "healthy"


app = Litestar(route_handlers=[health_check])
app = Litestar(route_handlers=[health_check], debug=True)


@pytest.fixture(scope="function")
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/testing/test_set_session_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_session_data(request: Request) -> Dict[str, Any]:
return request.session


app = Litestar(route_handlers=[get_session_data], middleware=[session_config.middleware])
app = Litestar(route_handlers=[get_session_data], middleware=[session_config.middleware], debug=True)


def test_get_session_data() -> None:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/testing/test_set_session_data_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_session_data(request: Request) -> Dict[str, Any]:
return request.session


app = Litestar(route_handlers=[get_session_data], middleware=[session_config.middleware])
app = Litestar(route_handlers=[get_session_data], middleware=[session_config.middleware], debug=True)


async def test_get_session_data() -> None:
Expand Down
8 changes: 8 additions & 0 deletions docs/usage/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ We would then test it using the test client like so:

from my_app.main import app

app.debug = True


def test_health_check():
with TestClient(app=app) as client:
Expand All @@ -60,6 +62,8 @@ We would then test it using the test client like so:

from my_app.main import app

app.debug = True


async def test_health_check():
async with AsyncTestClient(app=app) as client:
Expand Down Expand Up @@ -90,6 +94,8 @@ Since we would probably need to use the client in multiple places, it's better t
if TYPE_CHECKING:
from litestar import Litestar

app.debug = True


@pytest.fixture(scope="function")
def test_client() -> Iterator[TestClient[Litestar]]:
Expand All @@ -114,6 +120,8 @@ Since we would probably need to use the client in multiple places, it's better t
if TYPE_CHECKING:
from litestar import Litestar

app.debug = True


@pytest.fixture(scope="function")
async def test_client() -> AsyncIterator[AsyncTestClient[Litestar]]:
Expand Down
Loading