diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..8c80a1a --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,45 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + permissions: + contents: read + pull-requests: write + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - 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 + python -m 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 and calculate coverage + 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 }} diff --git a/__pycache__/functions.cpython-311.pyc b/__pycache__/functions.cpython-311.pyc new file mode 100644 index 0000000..7092918 Binary files /dev/null and b/__pycache__/functions.cpython-311.pyc differ diff --git a/__pycache__/test_functions.cpython-311-pytest-7.2.1.pyc b/__pycache__/test_functions.cpython-311-pytest-7.2.1.pyc new file mode 100644 index 0000000..b0aea52 Binary files /dev/null and b/__pycache__/test_functions.cpython-311-pytest-7.2.1.pyc differ diff --git a/test_functions.py b/test_functions.py index ffd7a65..c54f132 100644 --- a/test_functions.py +++ b/test_functions.py @@ -4,16 +4,12 @@ def test_add(): - assert add(2, 3) == 5 + assert add(2, 4) == 6 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)