From 70e6f3dc789e4ad8d68793c80b0be69c63909a3f Mon Sep 17 00:00:00 2001 From: oronce Date: Mon, 19 Jun 2023 02:38:24 +0100 Subject: [PATCH 1/3] add test and githubactions --- .github/workflows/ci_cd_wf.yml | 29 +++++++++++++++++++++++++++++ .gitignore | 1 + tests/test_calculator.py | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 .github/workflows/ci_cd_wf.yml diff --git a/.github/workflows/ci_cd_wf.yml b/.github/workflows/ci_cd_wf.yml new file mode 100644 index 00000000..8ca03d4c --- /dev/null +++ b/.github/workflows/ci_cd_wf.yml @@ -0,0 +1,29 @@ +name: test + +on: + push: + branches: + - main + pull_request: + branches: + - "*" + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Check out repo code + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: "3.x" + + - name: Install Dependencies + run: | + python -m pip install -r requirements.txt + - name: Run tests + run: | + python -m pytest -v tests \ No newline at end of file diff --git a/.gitignore b/.gitignore index b1cb1601..5e8f6be6 100644 --- a/.gitignore +++ b/.gitignore @@ -159,3 +159,4 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +.vscode/ \ No newline at end of file diff --git a/tests/test_calculator.py b/tests/test_calculator.py index e69de29b..aeae4a4d 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -0,0 +1,17 @@ +from calculator import add, div, mul, sub + + +def test_add(): + assert add(1, 1) == 2 + + +def test_sub(): + assert sub(1, 1) == 0 + + +def test_mul(): + assert mul(1, 1) == 1 + + +def test_div(): + assert div(2, 1) == 2 \ No newline at end of file From d03405d7da52ffe263d1f867d0018308ce5fea0a Mon Sep 17 00:00:00 2001 From: oronce Date: Mon, 19 Jun 2023 02:39:38 +0100 Subject: [PATCH 2/3] error simulation for failed test --- tests/test_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_calculator.py b/tests/test_calculator.py index aeae4a4d..1a7ee7fb 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -2,7 +2,7 @@ def test_add(): - assert add(1, 1) == 2 + assert add(1, 1) == 0 def test_sub(): From d6c8bdcdd9821b9d24819e73e320b45bcac6af5f Mon Sep 17 00:00:00 2001 From: oronce Date: Mon, 19 Jun 2023 02:47:32 +0100 Subject: [PATCH 3/3] fix the simulate error in the test --- tests/test_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_calculator.py b/tests/test_calculator.py index 1a7ee7fb..aeae4a4d 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -2,7 +2,7 @@ def test_add(): - assert add(1, 1) == 0 + assert add(1, 1) == 2 def test_sub():