Skip to content

Commit b71ff94

Browse files
author
Koman Rudden
committed
Refactor test_flask_framework.py: reduce duplication and improve code quality
- Extract BaseFlaskFrameworkTest base class with common setUp/tearDown logic to eliminate ~100 lines of duplicated code across 4 test classes - Replace try/except blocks with idiomatic shutil.rmtree(ignore_errors=True) - Prefix unused mock parameters with _ to signal intentional non-use and silence linter warnings (18 parameters updated) - Fix framework tracking in test_session_directory_permissions by renaming to _framework (mocks prevent real directory creation)
1 parent 3eb1cc9 commit b71ff94

2 files changed

Lines changed: 69 additions & 150 deletions

File tree

kinde_fastapi/examples/example_app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
- /user - Returns user information (redirects to login if not authenticated)
3131
"""
3232

33-
from fastapi import FastAPI, Request
33+
from fastapi import FastAPI
3434
from fastapi.responses import HTMLResponse, RedirectResponse
3535
from .session import InMemorySessionMiddleware
3636
import os
@@ -64,7 +64,7 @@
6464

6565
# Example home route
6666
@app.get("/", response_class=HTMLResponse)
67-
async def home(request: Request):
67+
async def home():
6868
"""
6969
Home page that shows different content based on authentication status.
7070
"""
@@ -95,7 +95,7 @@ async def home(request: Request):
9595
"""
9696
except Exception as e:
9797
error_msg = html.escape(str(e))
98-
logger.error(f"Error getting user info: {e}")
98+
logger.exception("Error getting user info")
9999
return f"""
100100
<html>
101101
<body>
@@ -134,7 +134,7 @@ async def protected_route():
134134
"user": user.get('email')
135135
}
136136
except Exception as e:
137-
logger.error(f"Error getting user info in protected route: {e}")
137+
logger.exception("Error getting user info in protected route")
138138
return RedirectResponse("/login")
139139

140140

0 commit comments

Comments
 (0)