Skip to content

Commit e31df78

Browse files
committed
3.Test file added
1 parent ba5d70a commit e31df78

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

_test.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import pytest
2+
3+
#functions to test suare
4+
5+
6+
def square(x): return x ** 2
7+
def cube(x): return x ** 3
8+
def fifth_power(x): return x ** 5
9+
10+
11+
#testing functions
12+
13+
def test_square():
14+
assert square(2) == 4
15+
assert square(-3) == 9
16+
assert square(0) == 0
17+
18+
19+
20+
def test_cube():
21+
assert cube(2) == 8
22+
assert cube(-3) == -27
23+
assert cube(0) == 0
24+
25+
26+
def test_fifth_power():
27+
assert fifth_power(2) == 32
28+
assert fifth_power(-3) == -243
29+
assert fifth_power(0) == 0
30+
31+
32+
33+
#Test for invalid input
34+
35+
def test_invalid_input():
36+
with pytest.raises(TypeError):
37+
square("string")

0 commit comments

Comments
 (0)