Skip to content

Commit f9252f5

Browse files
committed
Add function-to-be-test and the corresponding unit test
1 parent 9223614 commit f9252f5

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

funcs/func.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
def sum(x: float, y: float) -> float:
2-
return x + y
2+
return x + y
3+
4+
def misformatted_func(
5+
var1, var2, var3
6+
):
7+
print(var1, var2, var3)

tests/test_func.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import unittest
2+
from unittest.mock import patch
23
from funcs import func
34

45
class Test(unittest.TestCase):
56

67
def test_sum(self):
78
self.assertEqual(func.sum(2,3), 5)
89

10+
@patch('funcs.func.misformatted_func')
11+
def test_misformatted_func(self, mock_misformatted_func):
12+
func.misformatted_func("one", "two", "three")
13+
mock_misformatted_func.assert_called_with("one", "two", "three")
14+
915
if __name__ == "__main__":
1016
unittest.main()

0 commit comments

Comments
 (0)