forked from A-zhudong/python-exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
abregman
committed
Feb 27, 2022
1 parent
5830168
commit 05f672d
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Calculator - Unit Tests | ||
|
||
Write unit tests for the following functions | ||
|
||
```python | ||
def add(x, y): | ||
"""Add numbers""" | ||
return x + y | ||
|
||
def substract(x, y): | ||
"""Substract numbers""" | ||
return x - y | ||
|
||
def multiply(x, y): | ||
"""Multiply numbers""" | ||
|
||
def divide(x, y): | ||
"""Divide numbers""" | ||
if y == 0: | ||
raise ValueError('Can not divide by zero!') | ||
return x / y | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
## Fix Calculator Tests | ||
|
||
Fix the following Python test file to run successfully the tests | ||
|
||
```python | ||
import unittest | ||
import calc | ||
|
||
class TestCalculator(unittest.TestCase): | ||
|
||
def add_test(self): | ||
self.assertEqual(calculator.add(1, 1), 2) | ||
|
||
|
||
def test_substract(): | ||
self.assertEqual(calculator.substract(4, 3), 1) | ||
``` |