1- import io , sys , pytest , os , re , mock
1+ import io , sys , pytest , os , re , mock , app
2+
3+ # @pytest.mark.it('The function swap_digits must exist')
4+ # def test_for_functon_existence():
5+ # assert callable(app.swap_digits)
26
37@pytest .mark .it ('The function swap_digits must exist' )
4- def test_for_functon_existence ( capsys , app ):
5- assert callable ( app .swap_digits )
8+ def test_function_exists ( ):
9+ assert app .swap_digits
610
711@pytest .mark .it ('The function swap_digits must return something' )
8- def test_for_functon_return_statement (capsys , app ):
9- path = os .path .dirname (os .path .abspath (__file__ ))+ '/app.py'
10- with open (path , 'r' ) as content_file :
11- content = content_file .read ()
12- regex = re .compile (r"return(\s*)[^a-zA-Z0-9_]\w+" )
13- assert bool (regex .search (content )) == True
12+ def test_return_exists ():
13+ assert app .swap_digits (12 ) != None
1414
15+ @pytest .mark .it ('The function swap_digits should return an integer' )
16+ def test_return_integer ():
17+ assert type (app .swap_digits (23 )) == type (1 )
1518
16- @pytest .mark .it ('If `swap_digits` recieve 30 should return 3 as an integer ' )
19+ @pytest .mark .it ('If `swap_digits` recieve 30 should return 3' )
1720def test_for_file_output (capsys , app ):
1821 assert app .swap_digits (30 ) == 3
1922
20- @pytest .mark .it ('The function `swap_digits` must swap the digits of a 2 digits integer ' )
23+ @pytest .mark .it ('The function `swap_digits` must swap the digits' )
2124def test_for_file_output (capsys , app ):
22- assert app .swap_digits (79 ) == 97
23-
24-
25-
26-
27-
25+ assert app .swap_digits (79 ) == 97 or app .swap_digits (79 ) == "97"
0 commit comments