From beeffe8bdce05a7ddc3fdd8822581a0a4db3c43f Mon Sep 17 00:00:00 2001 From: Beau Carnes Date: Mon, 15 Jun 2020 16:48:23 -0400 Subject: [PATCH 1/3] INIT --- .gitignore | 127 ++++++++++++++++++++++++++++++++++++++++++ .vscode/launch.json | 11 ++++ .vscode/settings.json | 13 +++++ Makefile | 5 ++ pyvenv.cfg | 3 + requirements.txt | 10 ++++ src/example.py | 12 ++++ tests/__init__.py | 0 tests/context.py | 6 ++ tests/math_test.py | 18 ++++++ 10 files changed, 205 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 Makefile create mode 100644 pyvenv.cfg create mode 100644 requirements.txt create mode 100644 src/example.py create mode 100644 tests/__init__.py create mode 100644 tests/context.py create mode 100644 tests/math_test.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f0a236 --- /dev/null +++ b/.gitignore @@ -0,0 +1,127 @@ +# Editors +.idea/ + +# Vagrant +.vagrant/ + +# Mac/OSX +.DS_Store + +# Windows +Thumbs.db + +# Source for the following rules: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# binary +*.pyc \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..142f0a3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "configurations": [ + { + "name": "Python: Current File", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..61d5af2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + "[python]": { + "editor.rulers": [ + 72, + 79 + ], + "editor.tabSize": 4, + "editor.insertSpaces": true + }, + "python.linting.pylintEnabled": true, + "python.linting.lintOnSave": true, + "python.formatting.provider": "yapf" +} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1077f5c --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +init: + pip install -r requirements.txt + +test: + python tests/*_test.py \ No newline at end of file diff --git a/pyvenv.cfg b/pyvenv.cfg new file mode 100644 index 0000000..2518a82 --- /dev/null +++ b/pyvenv.cfg @@ -0,0 +1,3 @@ +home = /usr/local/bin +include-system-site-packages = false +version = 3.7.7 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9b14c1a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,10 @@ +astroid==2.4.2 +isort==4.3.21 +lazy-object-proxy==1.4.3 +mccabe==0.6.1 +pylint==2.5.3 +six==1.15.0 +tap.py==3.0 +toml==0.10.1 +typed-ast==1.4.1 +wrapt==1.12.1 \ No newline at end of file diff --git a/src/example.py b/src/example.py new file mode 100644 index 0000000..a2f720c --- /dev/null +++ b/src/example.py @@ -0,0 +1,12 @@ +# Solution +def add(*args): + '''Add 1 or more numbers together''' + return 0 + +def main(): + print('add(1) = ' + str(add(1))) + print('add(1, 2) = ' + str(add(1, 2))) + print('add(1, 2, 3) = ' + str(add(1, 2, 3))) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/context.py b/tests/context.py new file mode 100644 index 0000000..56d9144 --- /dev/null +++ b/tests/context.py @@ -0,0 +1,6 @@ +import sys +import os +sys.path.insert(0, os.path.abspath( + os.path.join(os.path.dirname(__file__), '..'))) + +import src \ No newline at end of file diff --git a/tests/math_test.py b/tests/math_test.py new file mode 100644 index 0000000..11afe1e --- /dev/null +++ b/tests/math_test.py @@ -0,0 +1,18 @@ +import unittest +import sys +sys.path.append('./src') + +from example import add + +class MathTest(unittest.TestCase): + def test_add_no_numbers(self): + self.assertEqual(add(), 0, "Should return 0 with no params") + def test_add_one_number(self): + self.assertEqual(add(1), 1, "Should add one number to 0") + def test_add_two_numbers(self): + self.assertEqual(add(1, 2), 3, "Should add two numbers together") + def test_add_three_numbers(self): + self.assertEqual(add(1, 2, 3), 6, "Should add three numbers together") + +if __name__ == '__main__': + unittest.main() \ No newline at end of file From 03ca32012287bb9e32723442bb8bbd7582bda236 Mon Sep 17 00:00:00 2001 From: Beau Carnes Date: Mon, 15 Jun 2020 15:38:43 -0400 Subject: [PATCH 2/3] 1.1 Sum function --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4f0a236..4c7d81f 100644 --- a/.gitignore +++ b/.gitignore @@ -124,4 +124,4 @@ venv.bak/ dmypy.json # binary -*.pyc \ No newline at end of file +*.pyc From 3c77a83d44f0aabe7f72152dfda117e7ac25a5b2 Mon Sep 17 00:00:00 2001 From: Beau Carnes Date: Mon, 15 Jun 2020 15:42:10 -0400 Subject: [PATCH 3/3] 1.1S Sum function --- src/example.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/example.py b/src/example.py index a2f720c..15cb2e6 100644 --- a/src/example.py +++ b/src/example.py @@ -1,7 +1,10 @@ # Solution def add(*args): '''Add 1 or more numbers together''' - return 0 + total = 0 + for arg in args: + total += arg + return total def main(): print('add(1) = ' + str(add(1)))