Skip to content

Commit

Permalink
add pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
fs committed Jan 18, 2024
1 parent c159dbb commit 83c99aa
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 0 deletions.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions py/pytest_mini_project/simplemath.py
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
20 changes: 20 additions & 0 deletions py/pytest_mini_project/test_simplemath.py
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)

0 comments on commit 83c99aa

Please sign in to comment.