Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Python_App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LAMRINI Houda
Python_App
Commits
fe385e93
Commit
fe385e93
authored
4 months ago
by
LAMRINI Houda
Browse files
Options
Downloads
Patches
Plain Diff
Edit test_app.py
parent
4d1a5d05
No related branches found
No related tags found
No related merge requests found
Pipeline
#47518
failed
4 months ago
Stage: test
Stage: build_stage
Stage: deploy_stage
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_app.py
+14
-2
14 additions, 2 deletions
tests/test_app.py
with
14 additions
and
2 deletions
tests/test_app.py
+
14
−
2
View file @
fe385e93
import
sys
import
os
import
unittest
from
app
import
app
# Ajoute le répertoire parent au chemin pour pouvoir importer `app` correctement
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
..
'
)))
# Maintenant tu peux importer l'application correctement
from
app
import
app
# Assure-toi que 'app' est bien l'objet Flask dans ton fichier app.py
class
TestApp
(
unittest
.
TestCase
):
def
setUp
(
self
):
# Crée un client de test pour l'application Flask
self
.
client
=
app
.
test_client
()
def
test_home
(
self
):
response
=
app
.
test_client
().
get
(
'
/
'
)
# Fais une requête GET sur la page d'accueil et vérifie le code de réponse
response
=
self
.
client
.
get
(
'
/
'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment