Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ci-cd-exercise
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cedric Verstege
ci-cd-exercise
Commits
b25113ad
Commit
b25113ad
authored
1 month ago
by
wep23441
Browse files
Options
Downloads
Patches
Plain Diff
unit test rewritten
parent
df81f1df
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
case-2-test/test_wizard_calculator.py
+26
-26
26 additions, 26 deletions
case-2-test/test_wizard_calculator.py
with
26 additions
and
26 deletions
case-2-test/test_wizard_calculator.py
+
26
−
26
View file @
b25113ad
import
unit
test
import
math
import
py
test
from
wizard_calculator
import
(
summon_dragons
,
vanish_trolls
,
...
...
@@ -9,33 +9,33 @@ from wizard_calculator import (
)
class
TestWizardCalculator
(
unittest
.
TestCase
):
def
test_summon_dragons
(
self
):
self
.
assertEqual
(
summon_dragons
(
3
,
4
),
7
)
self
.
assertEqual
(
summon_dragons
(
-
2
,
5
),
3
)
self
.
assertAlmostEqual
(
summon_dragons
(
0.5
,
0.5
),
1.0
)
def
test_summon_dragons
():
assert
summon_dragons
(
1
,
2
)
==
3
assert
summon_dragons
(
-
1
,
1
)
==
0
assert
summon_dragons
(
0
,
0
)
==
0
def
test_vanish_trolls
():
assert
vanish_trolls
(
5
,
3
)
==
2
assert
vanish_trolls
(
0
,
5
)
==
-
5
assert
vanish_trolls
(
10
,
0
)
==
10
def
test_vanish_trolls
(
self
):
self
.
assertEqual
(
vanish_trolls
(
10
,
3
),
7
)
self
.
assertEqual
(
vanish_trolls
(
3
,
10
),
-
7
)
self
.
assertAlmostEqual
(
vanish_trolls
(
1.5
,
0.5
),
1.0
)
def
test_brew_potions
(
self
):
self
.
assertEqual
(
brew_potions
(
3
,
4
),
12
)
self
.
assertEqual
(
brew_potions
(
0
,
100
),
0
)
self
.
assertAlmostEqual
(
brew_potions
(
2.5
,
2
),
5.0
)
def
test_brew_potions
():
assert
brew_potions
(
2
,
3
)
==
6
assert
brew_potions
(
-
1
,
3
)
==
-
3
assert
brew_potions
(
0
,
100
)
==
0
def
test_cast_division_spell
(
self
):
self
.
assertEqual
(
cast_division_spell
(
10
,
2
),
5
)
self
.
assertAlmostEqual
(
cast_division_spell
(
7
,
3.5
),
2.0
)
with
self
.
assertRaises
(
ValueError
):
cast_division_spell
(
5
,
0
)
def
test_conjure_magic_circle_area
(
self
):
self
.
assertAlmostEqual
(
conjure_magic_circle_area
(
1
),
math
.
pi
)
self
.
assertAlmostEqual
(
conjure_magic_circle_area
(
0
),
0
)
self
.
assertAlmostEqual
(
conjure_magic_circle_area
(
2.5
),
math
.
pi
*
2.5
*
2.5
)
def
test_cast_division_spell
():
assert
cast_division_spell
(
6
,
3
)
==
2
assert
cast_division_spell
(
10
,
2
)
==
5
assert
cast_division_spell
(
7
,
7
)
==
1
with
pytest
.
raises
(
ValueError
):
cast_division_spell
(
1
,
0
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
def
test_conjure_magic_circle_area
():
assert
conjure_magic_circle_area
(
3
)
==
pytest
.
approx
(
28.274
,
0.001
)
assert
conjure_magic_circle_area
(
0
)
==
0
assert
conjure_magic_circle_area
(
1
)
==
pytest
.
approx
(
3.14159
,
0.001
)
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