File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ .DS_store
12# Byte-compiled / optimized / DLL files
23__pycache__ /
34* .py [cod ]
Original file line number Diff line number Diff line change 1+ '''
2+ A simple addition function.
3+ '''
4+ def add (a , b ):
5+ return a + b
Original file line number Diff line number Diff line change 1+ import calc
2+ import unittest
3+
4+ class TestAdd (unittest .TestCase ):
5+ """
6+ Test the add function from the calc library
7+ """
8+
9+ def test_add_integers (self ):
10+ """
11+ Test that the addition of two integers returns the correct total
12+ """
13+ result = calc .add (1 , 2 )
14+ self .assertEqual (result , 3 )
15+
16+ def test_add_floats (self ):
17+ """
18+ Test that the addition of two floats returns the correct result
19+ """
20+ result = calc .add (10.5 , 2 )
21+ self .assertEqual (result , 12.5 )
22+
23+ def test_add_strings (self ):
24+ """
25+ Test the addition of two strings returns the two string as one
26+ concatenated string
27+ """
28+ result = calc .add ('abc' , 'def' )
29+ self .assertEqual (result , 'abcdef' )
30+
31+
32+ if __name__ == '__main__' :
33+ unittest .main ()
You can’t perform that action at this time.
0 commit comments