From f53768612b1e2268697b5444e502032ef9f3fb3c Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 23 May 2023 23:45:12 -0400 Subject: copying from old repo --- extension/examples/tests/__init__.py | 0 extension/examples/tests/test_main.py | 39 +++++++++++++++++++++++++++++++++++ extension/examples/tests/test_sum.py | 12 +++++++++++ 3 files changed, 51 insertions(+) create mode 100644 extension/examples/tests/__init__.py create mode 100644 extension/examples/tests/test_main.py create mode 100644 extension/examples/tests/test_sum.py (limited to 'extension/examples/tests') diff --git a/extension/examples/tests/__init__.py b/extension/examples/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/extension/examples/tests/test_main.py b/extension/examples/tests/test_main.py new file mode 100644 index 00000000..ff952dd8 --- /dev/null +++ b/extension/examples/tests/test_main.py @@ -0,0 +1,39 @@ + +import pytest + +from ..calculator import Calculator + + +@pytest.fixture +def calculator(): + return Calculator() + + +def test_add(calculator): + assert calculator.add(2, 3) == 5 + assert calculator.add(10, -2) == 8 + assert calculator.add(0, 0) == 0 + + +def test_sub(calculator): + assert calculator.sub(2, 3) == -1 + assert calculator.sub(10, -2) == 12 + assert calculator.sub(0, 0) == 0 + + +def test_mul(calculator): + assert calculator.mul(2, 3) == 6 + assert calculator.mul(10, -2) == -20 + assert calculator.mul(0, 0) == 0 + + +def test_div(calculator): + assert calculator.div(2, 3) == 0.6666666666666666 + assert calculator.div(10, -2) == -5 + assert calculator.div(0, 1) == 0 + + +def test_exp(calculator): + assert calculator.exp(2, 3) == 8 + assert calculator.exp(10, -2) == 0.01 + assert calculator.exp(0, 0) == 1 diff --git a/extension/examples/tests/test_sum.py b/extension/examples/tests/test_sum.py new file mode 100644 index 00000000..caef7c07 --- /dev/null +++ b/extension/examples/tests/test_sum.py @@ -0,0 +1,12 @@ +import pytest +# print(__name__) +# from ..sum import sum as real_sum + +def sum(a, b): + return a + b + +def test_sum(): + assert sum(1, 2) == 3 + +def test_abc(): + assert True \ No newline at end of file -- cgit v1.2.3-70-g09d2