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
30 changes: 30 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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 Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: checkout code
uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Run tests
run: |
python -m unittest test.py

Empty file added __init__.py
Empty file.
Binary file added __pycache__/main.cpython-312.pyc
Binary file not shown.
26 changes: 19 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@

def fizzbuzz(num):
if num%3 == 0 and num % 5 == 0:
return "fizzbuzz"
elif num%3 == 0:
return "fizz"
elif num % 5 == 0:
return "buzz"
else:
return str(num)

def main():
print('Hello, World!')
return 0

if __name__ == '__main__':
main()

for i in range(1, 101):
if i%3 == 0 and i % 5 == 0:
return "fizzbuzz"
elif i%3 == 0:
return "fizz"
elif i % 5 == 0:
return "buzz"
else:
return str(i)
19 changes: 19 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import unittest;
from main import fizzbuzz;

class TestFizzbuzz(unittest.TestCase):
def test_isFizz(self):
fizzbuzz(3)
self.assertEqual(fizzbuzz(3), "fizz")
def test_isBuzz(self):
fizzbuzz(5)
self.assertEqual(fizzbuzz(5), "buzz")
def test_isFizzbuzz(self):
fizzbuzz(15)
self.assertEqual(fizzbuzz(15), "fizz")
def test_isNumber(self):
fizzbuzz(1)
self.assertEqual(fizzbuzz(1), "1")

if __name__ == '__main__':
unittest.main()