Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -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 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 }}
Binary file added __pycache__/functions.cpython-312.pyc
Binary file not shown.
Binary file not shown.
6 changes: 4 additions & 2 deletions functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ def add(a, b):


def subtract(a, b):
return a + b
return a - b


def multiply(a, b):
return a * b


def convert_fahrenheit_to_celsius(fahrenheit):
return multiply(subtract(fahrenheit, 32), 9 / 5)
if fahrenheit < -459.67:
raise AssertionError("Temperature below absolute zero is not possible.")
return multiply(subtract(fahrenheit, 32), 5 / 9)
14 changes: 7 additions & 7 deletions test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)