1+ import io , sys , os , re , pytest
2+ import app
3+
4+ @pytest .mark .it ('You should create a function named square_root' )
5+ def test_square_root_exists (app ):
6+ try :
7+ from app import square_root
8+ assert square_root
9+ except AttributeError :
10+ raise AttributeError ("The function 'square_root' should exist on app.py" )
11+
12+ @pytest .mark .it ('The function must return something' )
13+ def test_function_return (capsys , app ):
14+ assert app .square_root (25 ) != None
15+
16+ @pytest .mark .it ('The function must return a float number' )
17+ def test_function_return_type (capsys , app ):
18+ assert type (app .square_root (25 )) == type (1.0 )
19+
20+ @pytest .mark .it ('Testing the function square_root with the number 50, it should return 7.07' )
21+ def test_square_root_50 (app ):
22+ try :
23+ assert app .square_root (50 ) == 7.07
24+ except AttributeError :
25+ raise AttributeError ("The function 'square_root' should return the value 7.07" )
26+
27+ @pytest .mark .it ('Testing the function square_root with the number 2.25, it should return 1.5' )
28+ def test_square_root_2_25 (app ):
29+ try :
30+ assert app .square_root (2.25 ) == 1.5
31+ except AttributeError :
32+ raise AttributeError ("The function 'square_root' should return the value 1.5" )
33+
34+ @pytest .mark .it ('Testing the function square_root with the number 0, it should return 0' )
35+ def test_square_root_0 (app ):
36+ try :
37+ assert app .square_root (0 ) == 0
38+ except AttributeError :
39+ raise AttributeError ("The function 'square_root' should return the value 0" )
0 commit comments