diff --git a/.gitignore b/.gitignore index 373c5df..4c7d81f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,127 @@ -node_modules -package-lock.json -.DS_Store \ No newline at end of file +# 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 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/TUTORIAL.md b/TUTORIAL.md deleted file mode 100644 index 77e0647..0000000 --- a/TUTORIAL.md +++ /dev/null @@ -1,25 +0,0 @@ -# Basic Python Example - -A test to try Python with CodeRoad - -## 1. Add some numbers together - -> Test out the basics - - - -This is just a test, so here's the answer: - -```py -def add(*args): - '''Add 1 or more numbers together''' - total = 0 - for arg in args: - total += arg - return total -``` - -### 1.1 Add - -Complete the `add` function. It should be able to add one or more numbers together. -For example: `add(1) = 1`, `add(1, 2) = 3`, and `add(1, 2, 3) = 6`. diff --git a/coderoad.yaml b/coderoad.yaml deleted file mode 100644 index a1a4b9b..0000000 --- a/coderoad.yaml +++ /dev/null @@ -1,21 +0,0 @@ -version: '0.1.1' -config: - testRunner: - command: python3 - args: - tap: -m tap tests/*_test.py - filter: --match - setup: - commands: - - pip3 install -r requirements.txt - repo: - uri: https://github.com/shmck/coderoad-python-test - branch: v0.1.1 -levels: - - id: '1' - steps: - - id: '1.1' - setup: - files: - - src/example.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..15cb2e6 --- /dev/null +++ b/src/example.py @@ -0,0 +1,15 @@ +# Solution +def add(*args): + '''Add 1 or more numbers together''' + total = 0 + for arg in args: + total += arg + return total + +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 diff --git a/tutorial.json b/tutorial.json deleted file mode 100644 index 064e903..0000000 --- a/tutorial.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "version": "0.1.1", - "summary": { - "title": "Basic Python Example", - "description": "A test to try Python with CodeRoad" - }, - "config": { - "testRunner": { - "command": "python3", - "args": { - "tap": "-m tap tests/*_test.py", - "filter": "--match" - } - }, - "setup": { - "commands": [ - "pip3 install -r requirements.txt" - ], - "commits": [ - "beeffe8bdce05a7ddc3fdd8822581a0a4db3c43f" - ] - }, - "repo": { - "uri": "https://github.com/shmck/coderoad-python-test", - "branch": "v0.1.1" - } - }, - "levels": [ - { - "id": "1", - "title": "Add some numbers together", - "summary": "Test out the basics", - "content": "This is just a test, so here's the answer:\n\n```py\ndef add(*args):\n '''Add 1 or more numbers together'''\n total = 0\n for arg in args:\n total += arg\n return total\n```", - "steps": [ - { - "id": "1.1", - "setup": { - "files": [ - "src/example.py" - ], - "commits": [ - "03ca32012287bb9e32723442bb8bbd7582bda236" - ] - }, - "content": "Complete the `add` function. It should be able to add one or more numbers together. \nFor example: `add(1) = 1`, `add(1, 2) = 3`, and `add(1, 2, 3) = 6`.", - "solution": { - "commits": [ - "3c77a83d44f0aabe7f72152dfda117e7ac25a5b2" - ] - } - } - ] - } - ] -} \ No newline at end of file