Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CICD 2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Mathias Thirion
CICD 2022
Commits
2bab5561
Commit
2bab5561
authored
2 years ago
by
Mathias Thirion
Browse files
Options
Downloads
Patches
Plain Diff
test
parent
c39e5665
No related branches found
No related tags found
No related merge requests found
Pipeline
#46405
failed
2 years ago
Stage: dependencies
Stage: lint
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+10
-0
10 additions, 0 deletions
.gitlab-ci.yml
calculator/test_calculator.py
+9
-0
9 additions, 0 deletions
calculator/test_calculator.py
with
19 additions
and
0 deletions
.gitlab-ci.yml
+
10
−
0
View file @
2bab5561
...
@@ -28,4 +28,14 @@ pylint:
...
@@ -28,4 +28,14 @@ pylint:
# À toi de nous rajouter un petit job pour faire des tests unitaires
# À toi de nous rajouter un petit job pour faire des tests unitaires
pytest
:
pytest
:
stage
:
test
dependencies
:
-
download_dependencies
needs
:
-
download_dependencies
script
:
-
source .venv/bin/activate
-
pip install pytest
-
pytest calculator
## Bon courage
## Bon courage
This diff is collapsed.
Click to expand it.
calculator/test_calculator.py
+
9
−
0
View file @
2bab5561
...
@@ -25,6 +25,9 @@ def test_tokenizer(setup):
...
@@ -25,6 +25,9 @@ def test_tokenizer(setup):
"""
"""
plus
,
minus
,
times
,
divide
,
calc
=
setup
plus
,
minus
,
times
,
divide
,
calc
=
setup
assert
calc
.
tokenize
(
"
1 + 2
"
)
==
[
1
,
plus
,
2
]
assert
calc
.
tokenize
(
"
1 + 2
"
)
==
[
1
,
plus
,
2
]
assert
calc
.
tokenize
(
"
6 * 7 / 2
"
)
==
[
6
,
times
,
7
,
divide
,
2
]
assert
calc
.
tokenize
(
"
6 + 7 * 3
"
)
==
[
6
,
plus
,
7
,
times
,
3
]
assert
calc
.
tokenize
(
"
6 * 7 - 2 / 2
"
)
==
[
6
,
times
,
7
,
minus
,
2
,
divide
,
2
]
# À toi de tester la fonction tokenize de Calculator.
# À toi de tester la fonction tokenize de Calculator.
# Essaie de tester tous les opérateurs.
# Essaie de tester tous les opérateurs.
...
@@ -35,6 +38,9 @@ def test_parser(setup):
...
@@ -35,6 +38,9 @@ def test_parser(setup):
"""
"""
plus
,
minus
,
times
,
divide
,
calc
=
setup
plus
,
minus
,
times
,
divide
,
calc
=
setup
assert
repr
(
calc
.
parse
([
1
,
plus
,
2
]))
==
'
(1 + 2)
'
assert
repr
(
calc
.
parse
([
1
,
plus
,
2
]))
==
'
(1 + 2)
'
assert
repr
(
calc
.
parse
([
6
,
times
,
7
,
divide
,
2
]))
==
'
(6 * 7 / 2)
'
assert
repr
(
calc
.
parse
([
6
,
plus
,
7
,
times
,
2
]))
==
'
(6 + 7 * 2)
'
assert
repr
(
calc
.
parse
([
6
,
times
,
7
,
minus
,
2
,
divide
,
2
]))
==
'
(6 * 7 - 2 / 2)
'
# À toi de tester la fonction parse de Calculator.
# À toi de tester la fonction parse de Calculator.
# Essaie de tester tous les opérateurs.
# Essaie de tester tous les opérateurs.
...
@@ -45,5 +51,8 @@ def test_evaluation(setup):
...
@@ -45,5 +51,8 @@ def test_evaluation(setup):
"""
"""
plus
,
minus
,
times
,
divide
,
calc
=
setup
plus
,
minus
,
times
,
divide
,
calc
=
setup
assert
calc
(
"
1 + 2
"
)
==
3
assert
calc
(
"
1 + 2
"
)
==
3
assert
calc
(
"
6 * 7 / 2
"
)
==
21
assert
calc
(
"
6 + 7 * 2
"
)
==
20
assert
calc
(
"
6 * 7 - 2 / 2
"
)
==
41
# À toi de tester la fonction __call__ de Calculator.
# À toi de tester la fonction __call__ de Calculator.
# Essaie de tester tous les opérateurs.
# Essaie de tester tous les opérateurs.
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