-
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
fs
committed
Jan 18, 2024
1 parent
c159dbb
commit 83c99aa
Showing
7 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.91 KB
py/pytest_mini_project/__pycache__/test_simplemath.cpython-310-pytest-7.4.4.pyc
Binary file not shown.
Binary file not shown.
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,15 @@ | ||
# simplemath.py | ||
|
||
def add(a, b): | ||
return a + b | ||
|
||
def subtract(a, b): | ||
return a - b | ||
|
||
def multiply(a, b): | ||
return a * b | ||
|
||
def divide(a, b): | ||
if b == 0: | ||
raise ValueError("Cannot divide by zero") | ||
return a / b |
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,20 @@ | ||
# test_simplemath.py | ||
|
||
import pytest | ||
from pytest_mini_project.simplemath import add, subtract, multiply, divide | ||
|
||
def test_add(): | ||
assert add(1, 2) == 3 | ||
|
||
def test_subtract(): | ||
assert subtract(2, 1) == 1 | ||
|
||
def test_multiply(): | ||
assert multiply(2, 3) == 6 | ||
|
||
def test_divide(): | ||
assert divide(6, 2) == 3 | ||
|
||
def test_divide_by_zero(): | ||
with pytest.raises(ValueError): | ||
divide(1, 0) |