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/coderoad/Makefile b/coderoad/Makefile new file mode 100644 index 0000000..64a7d49 --- /dev/null +++ b/coderoad/Makefile @@ -0,0 +1,5 @@ +init: + pip install -r requirements.txt + +test: + python tests diff --git a/coderoad/pyvenv.cfg b/coderoad/pyvenv.cfg new file mode 100644 index 0000000..2518a82 --- /dev/null +++ b/coderoad/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/coderoad/requirements.txt b/coderoad/requirements.txt new file mode 100644 index 0000000..9b14c1a --- /dev/null +++ b/coderoad/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/coderoad/src/example.py b/coderoad/src/example.py new file mode 100644 index 0000000..b4e8f8b --- /dev/null +++ b/coderoad/src/example.py @@ -0,0 +1,16 @@ +# Solution +def add(*args): + '''Add 1 or more numbers together''' + sum = 0 + for arg in args: + sum += arg + return sum + +def main(): + print('hello') + print(str(add(1))) + print(str(add(1, 2))) + print(str(add(1, 2, 3))) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/coderoad/tests/context.py b/coderoad/tests/context.py new file mode 100644 index 0000000..56d9144 --- /dev/null +++ b/coderoad/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/coderoad/tests/math_test.py b/coderoad/tests/math_test.py new file mode 100644 index 0000000..206228b --- /dev/null +++ b/coderoad/tests/math_test.py @@ -0,0 +1,19 @@ +import unittest +import sys +sys.path.append('./coderoad/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