Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Praxisprojekt Technologiebasierte Innovationen
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
Container 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Rafeh
Praxisprojekt Technologiebasierte Innovationen
Commits
4de27f12
Commit
4de27f12
authored
2 weeks ago
by
Daniel Rafeh
Browse files
Options
Downloads
Patches
Plain Diff
Delete calculator.py
parent
64c5b16a
Loading
Loading
No related merge requests found
Pipeline
#19984
passed
2 weeks ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
calculator.py
+0
-66
0 additions, 66 deletions
calculator.py
with
0 additions
and
66 deletions
calculator.py
deleted
100644 → 0
+
0
−
66
View file @
64c5b16a
from
abc
import
ABC
,
abstractmethod
import
unittest
class
ICalculator
(
ABC
):
@abstractmethod
def
add
(
self
,
a
,
b
):
pass
@abstractmethod
def
sub
(
self
,
a
,
b
):
pass
@abstractmethod
def
mul
(
self
,
a
,
b
):
pass
@abstractmethod
def
div
(
self
,
a
,
b
):
pass
class
Calculator
(
ICalculator
):
def
add
(
self
,
a
,
b
):
return
a
+
b
def
sub
(
self
,
a
,
b
):
return
a
-
b
def
mul
(
self
,
a
,
b
):
return
a
*
b
def
div
(
self
,
a
,
b
):
if
b
==
0
:
raise
ValueError
(
"
Division durch die Zahl null ist nicht erlaubt
"
)
return
a
/
b
class
TestCalculator
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
calc
=
Calculator
()
# Test add-function
def
test_add
(
self
):
erg
=
self
.
calc
.
add
(
3
,
5
)
self
.
assertEqual
(
erg
,
8
)
# Test sub-function
def
test_sub
(
self
):
erg
=
self
.
calc
.
sub
(
10
,
3
)
self
.
assertEqual
(
erg
,
7
)
# Test mul-function
def
test_mul
(
self
):
erg
=
self
.
calc
.
mul
(
4
,
6
)
self
.
assertEqual
(
erg
,
24
)
# Test div-function
def
test_div
(
self
):
erg
=
self
.
calc
.
div
(
20
,
4
)
self
.
assertEqual
(
erg
,
5
)
# Test div/0
def
test_div_by_zero
(
self
):
with
self
.
assertRaises
(
ValueError
):
self
.
calc
.
div
(
10
,
0
)
if
__name__
==
"
__main__
"
:
unittest
.
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