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
Bilel El Yaagoubi
CICD 2022
Compare revisions
2072f264840a63ae4e8df29e6b6cb1bc394c06a3 to 4e5179c46d0da8f446f81955eaa508bc81c19a4b
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
octolel/cicd
Select target project
No results found
4e5179c46d0da8f446f81955eaa508bc81c19a4b
Select Git revision
Loading items
Swap
Target
octolel/cicd
Select target project
octolel/cicd
bruliette/cicd-2022-juju
desjardins/cicd
greets/cicd
2022faureal/cicd
2022flamama/cicd
2022thirionma/cicd
siestetactique/cicd
2021khlauthu/cicd
aubinx/cicd
2022jacquinar/cicd
gravlax/cicd
12 results
2072f264840a63ae4e8df29e6b6cb1bc394c06a3
Select Git revision
Loading items
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
fix tests
· 63593692
Bilel El Yaagoubi
authored
2 years ago
63593692
fix ci
· 4e5179c4
Bilel El Yaagoubi
authored
2 years ago
4e5179c4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+10
-1
10 additions, 1 deletion
.gitlab-ci.yml
calculator/calculator.py
+1
-1
1 addition, 1 deletion
calculator/calculator.py
calculator/operators.py
+2
-2
2 additions, 2 deletions
calculator/operators.py
calculator/test_calculator.py
+23
-14
23 additions, 14 deletions
calculator/test_calculator.py
with
36 additions
and
18 deletions
.gitlab-ci.yml
View file @
4e5179c4
...
@@ -31,4 +31,13 @@ pylint:
...
@@ -31,4 +31,13 @@ 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
:
## Bon courage
stage
:
test
dependencies
:
-
download_dependencies
needs
:
-
download_dependencies
before_script
:
-
source .venv/bin/activate
-
pip install pytest
script
:
-
pytest calculator
This diff is collapsed.
Click to expand it.
calculator/calculator.py
View file @
4e5179c4
...
@@ -54,7 +54,7 @@ class Calculator:
...
@@ -54,7 +54,7 @@ class Calculator:
#####################################################################
#####################################################################
### ATTENTION: Est-ce que c'est vraiment un < (non c'est un <=) ? ###
### ATTENTION: Est-ce que c'est vraiment un < (non c'est un <=) ? ###
#####################################################################
#####################################################################
if
operator
is
None
or
token
.
precedence
<
operator
.
precedence
:
if
operator
is
None
or
token
.
precedence
<
=
operator
.
precedence
:
operator
=
token
operator
=
token
operator_index
=
i
operator_index
=
i
...
...
This diff is collapsed.
Click to expand it.
calculator/operators.py
View file @
4e5179c4
...
@@ -21,6 +21,6 @@ class Operator:
...
@@ -21,6 +21,6 @@ class Operator:
STANDARD_OPERATORS
=
{
STANDARD_OPERATORS
=
{
'
+
'
:
Operator
(
'
+
'
,
1
,
lambda
a
,
b
:
a
+
b
),
'
+
'
:
Operator
(
'
+
'
,
1
,
lambda
a
,
b
:
a
+
b
),
'
-
'
:
Operator
(
'
-
'
,
1
,
lambda
a
,
b
:
a
-
b
),
'
-
'
:
Operator
(
'
-
'
,
1
,
lambda
a
,
b
:
a
-
b
),
'
*
'
:
Operator
(
'
×
'
,
2
,
lambda
a
,
b
:
a
*
b
),
'
*
'
:
Operator
(
'
*
'
,
2
,
lambda
a
,
b
:
a
*
b
),
'
/
'
:
Operator
(
'
/
'
,
2
,
lambda
a
,
b
:
a
%
b
),
'
/
'
:
Operator
(
'
/
'
,
2
,
lambda
a
,
b
:
a
/
b
),
}
}
This diff is collapsed.
Click to expand it.
calculator/test_calculator.py
View file @
4e5179c4
...
@@ -3,7 +3,7 @@ Test module for the calculator module.
...
@@ -3,7 +3,7 @@ Test module for the calculator module.
"""
"""
import
pytest
import
pytest
from
calculator.calculator
import
Calculator
from
calculator.calculator
import
Calculator
from
calculator.operators
import
Operator
from
calculator.operators
import
STANDARD_OPERATORS
,
Operator
@pytest.fixture
(
scope
=
"
module
"
,
name
=
"
setup
"
)
@pytest.fixture
(
scope
=
"
module
"
,
name
=
"
setup
"
)
...
@@ -11,20 +11,19 @@ def fixture_setup():
...
@@ -11,20 +11,19 @@ def fixture_setup():
"""
"""
Setup the test suite, by instantiating the calculator and the operators.
Setup the test suite, by instantiating the calculator and the operators.
"""
"""
plus
=
Operator
(
'
+
'
,
1
,
lambda
a
,
b
:
a
+
b
)
min
us
=
Operator
(
'
-
'
,
1
,
lambda
a
,
b
:
a
-
b
)
pl
us
=
STANDARD_OPERATORS
[
'
+
'
]
times
=
Operator
(
'
*
'
,
2
,
lambda
a
,
b
:
a
*
b
)
minus
=
STANDARD_OPERATORS
[
'
-
'
]
divide
=
Operator
(
'
/
'
,
2
,
lambda
a
,
b
:
a
/
b
)
times
=
STANDARD_OPERATORS
[
'
*
'
]
calculator
=
Calculator
(
divide
=
STANDARD_OPERATORS
[
'
/
'
]
operators
=
{
'
+
'
:
plus
,
'
-
'
:
minus
,
'
*
'
:
times
,
'
/
'
:
divide
}
)
calculator
=
Calculator
(
STANDARD_OPERATORS
)
yield
plus
,
minus
,
times
,
divide
,
calculator
yield
plus
,
minus
,
times
,
divide
,
calculator
def
test_tokenizer
(
setup
):
def
test_tokenizer
(
setup
):
"""
Test the tokenizer.
"""
plus
,
minus
,
times
,
divide
,
calc
=
setup
plus
,
minus
,
times
,
divide
,
calc
=
setup
assert
calc
.
tokenize
(
"
1 + 2 + 4 / 2
"
)
==
[
1
,
plus
,
2
,
plus
,
4
,
divide
,
2
]
assert
calc
.
tokenize
(
"
1 * 0 - 4 / 2
"
)
==
[
1
,
times
,
0
,
minus
,
4
,
divide
,
2
]
# À toi de tester la fonction tokenize de Calculator.
# À toi de tester la fonction tokenize de Calculator.
...
@@ -32,13 +31,23 @@ def test_parser(setup):
...
@@ -32,13 +31,23 @@ def test_parser(setup):
"""
"""
Test the parser.
Test the parser.
"""
"""
plus
,
minus
,
times
,
divide
,
calc
=
setup
_
,
_
,
_
,
_
,
calc
=
setup
# À toi de tester la fonction parse de Calculator.
assert
repr
(
calc
.
parse
(
calc
.
tokenize
(
"
1 + 2
"
)))
==
'
(1 + 2)
'
assert
repr
(
calc
.
parse
(
calc
.
tokenize
(
"
1 + 2 * 3
"
))
)
==
'
(1 + (2 * 3))
'
assert
repr
(
calc
.
parse
(
calc
.
tokenize
(
"
1 + 2 * 3 / 4
"
)))
==
'
(1 + ((2 * 3) / 4))
'
assert
repr
(
calc
.
parse
(
calc
.
tokenize
(
"
1 + 2 * 3 / 4 - 5
"
)))
==
'
((1 + ((2 * 3) / 4)) - 5)
'
def
test_evaluation
(
setup
):
def
test_evaluation
(
setup
):
"""
"""
Test the evaluation.
Test the evaluation.
"""
"""
plus
,
minus
,
times
,
divide
,
calc
=
setup
_
,
_
,
_
,
_
,
calc
=
setup
# À toi de tester la fonction __call__ de Calculator.
assert
calc
(
"
1 + 2
"
)
==
3
assert
calc
(
"
1 + 2 * 3
"
)
==
7
assert
calc
(
"
1 + 2 * 3 / 4
"
)
==
2.5
assert
calc
(
"
1 + 2 * 3 / 4 - 5
"
)
==
-
2.5
This diff is collapsed.
Click to expand it.