From 6dc3d5e61ea8b08b53c965d24cfd4310d14c9557 Mon Sep 17 00:00:00 2001 From: 2019movie <100336464+2019movie@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:58:14 +0800 Subject: [PATCH 1/3] Create python-app.yml (default (given) commit message used (0912) --- .github/workflows/python-app.yml | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..cbb9a7d --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,46 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python application + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + pull-requests: write + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest pytest-cov + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest --cov-report "xml:coverage.xml" --cov=. + - name: Create Coverage + if: ${{ github.event_name == 'pull_request' }} + uses: orgoro/coverage@v3 + with: + coverageFile: coverage.xml + token: ${{ secrets.GITHUB_TOKEN }} From ab20079af5999af2b8dc0d681fb4dfd5c7a55687 Mon Sep 17 00:00:00 2001 From: 20062443 <20062443@tafe.wa.edu.au> Date: Thu, 12 Sep 2024 14:01:55 +0800 Subject: [PATCH 2/3] uncommented test_functions.py --- test_functions.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test_functions.py b/test_functions.py index ffd7a65..88fd496 100644 --- a/test_functions.py +++ b/test_functions.py @@ -8,12 +8,12 @@ def test_add(): assert add("space", "ship") == "spaceship" -# def test_subtract(): -# assert subtract(3,2) == 1 + def test_subtract(): + assert subtract(3,2) == 1 -# def test_convert_fahrenheit_to_celsius(): -# assert f2c(32) == 0 -# assert f2c(122) == pytest.approx(50) -# with pytest.raises(AssertionError): -# f2c(-600) + def test_convert_fahrenheit_to_celsius(): + assert f2c(32) == 0 + assert f2c(122) == pytest.approx(50) + with pytest.raises(AssertionError): + f2c(-600) From 03d16b7f500026f116e9b704e718e0fb0a184742 Mon Sep 17 00:00:00 2001 From: 20062443 <20062443@tafe.wa.edu.au> Date: Thu, 12 Sep 2024 14:14:59 +0800 Subject: [PATCH 3/3] fix subtract --- functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.py b/functions.py index 7cdbb28..cb7551c 100644 --- a/functions.py +++ b/functions.py @@ -3,7 +3,7 @@ def add(a, b): def subtract(a, b): - return a + b + return a - b def multiply(a, b):