Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a51b0f7

Browse files
committed
INIT example
1 parent 73edaa0 commit a51b0f7

File tree

6 files changed

+32
-18
lines changed

6 files changed

+32
-18
lines changed

coderoad-starter/src/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
from math import Add
2-
from math import Subtract
1+
from .example import add

coderoad-starter/src/example.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def add(*args):
2+
'''Add 1 or more numbers together'''
3+
sum = 0
4+
for arg in args:
5+
sum += arg
6+
return sum
7+
8+
def main():
9+
print('hello')
10+
print(str(add(1)))
11+
print(str(add(1, 2)))
12+
print(str(add(1, 2, 3)))
13+
14+
if __name__ == '__main__':
15+
main()

coderoad-starter/src/math.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

coderoad-starter/tests/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
sys.path.insert(0, os.path.abspath(
44
os.path.join(os.path.dirname(__file__), '..')))
55

6-
import src
6+
import src

coderoad-starter/tests/math_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import unittest
2+
from context import src
3+
4+
class MathTest(unittest.TestCase):
5+
def test_add_no_numbers(self):
6+
self.assertEqual(src.add(), 0, "Should return 0 with no params")
7+
def test_add_one_number(self):
8+
self.assertEqual(src.add(1), 1, "Should add one number to 0")
9+
def test_add_two_numbers(self):
10+
self.assertEqual(src.add(1, 2), 3, "Should add two numbers together")
11+
def test_add_three_numbers(self):
12+
self.assertEqual(src.add(1, 2, 3), 6, "Should add three numbers together")
13+
14+
if __name__ == '__main__':
15+
unittest.main()

coderoad-starter/tests/mock_test.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)