mirror of
https://gitlab.com/MisterBiggs/testing-framework-comparison.git
synced 2025-08-03 11:51:28 +00:00
init comit
This commit is contained in:
BIN
pytest/__pycache__/test_test.cpython-313-pytest-8.3.5.pyc
Normal file
BIN
pytest/__pycache__/test_test.cpython-313-pytest-8.3.5.pyc
Normal file
Binary file not shown.
50
pytest/test_test.py
Normal file
50
pytest/test_test.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import pytest
|
||||
|
||||
# Thanks to https://pydevtools.com/handbook/tutorial/setting-up-testing-with-pytest-and-uv/
|
||||
# for the guide
|
||||
|
||||
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
|
||||
|
||||
|
||||
def test_add():
|
||||
assert add(1, 2) == 3
|
||||
assert add(-1, 1) == 0
|
||||
assert add(-1, -1) == -2
|
||||
|
||||
|
||||
def test_subtract():
|
||||
assert subtract(3, 2) == 1
|
||||
assert subtract(2, 3) == -1
|
||||
assert subtract(0, 0) == 0
|
||||
|
||||
|
||||
def test_multiply():
|
||||
assert multiply(2, 3) == 6
|
||||
assert multiply(-2, 3) == -6
|
||||
assert multiply(-2, -3) == 6
|
||||
|
||||
|
||||
def test_divide():
|
||||
assert divide(6, 3) == 2
|
||||
assert divide(6, -3) == -2
|
||||
assert divide(-6, -3) == 2
|
||||
|
||||
|
||||
def test_divide_by_zero():
|
||||
with pytest.raises(ValueError):
|
||||
divide(5, 0)
|
Reference in New Issue
Block a user