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+ import pytest
2+
3+ import calculator
4+
5+
6+ class TestAddClass :
7+ calc = calculator .Calculator ()
8+
9+ def test_add_ (self ):
10+ assert self .calc .add (3 , 5 ) == 8
11+
12+ def test_add_with_one_negative (self ):
13+ assert self .calc .add (- 5 , 5 ) == 0
14+
15+ def test_add_with_two_negative (self ):
16+ assert self .calc .add (- 5 , - 5 ) == - 10
17+
18+ def test_type_error (self ):
19+ with pytest .raises (TypeError ):
20+ self .calc .add (3 , '6' )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ import calculator
4+
5+
6+ class TestDivClass :
7+ calc = calculator .Calculator ()
8+
9+ def test_division_with_zero (self ):
10+ with pytest .raises (ZeroDivisionError ):
11+ self .calc .div (213213 , 0 )
12+
13+ def test_division (self ):
14+ assert self .calc .div (5555 , 5 ) == 1111
15+
16+ def test_division_with_one_negative (self ):
17+ assert self .calc .div (- 54 , 9 ) == - 6
18+
19+ def test_division_with_two_negative (self ):
20+ assert self .calc .div (- 35 , - 5 ) == 7
21+
22+ def test_division_part (self ):
23+ assert self .calc .div (10 , 4 ) == 2.5
24+
25+ def test_type_error (self ):
26+ with pytest .raises (TypeError ):
27+ self .calc .add (3 , '6' )
Original file line number Diff line number Diff line change 1+ import pytest
2+ import calculator
3+
4+
5+ class TestMulClass :
6+ calc = calculator .Calculator ()
7+
8+ def test_multiple_with_zero (self ):
9+ assert self .calc .mul (213213 , 0 ) == 0
10+
11+ def test_multiple (self ):
12+ assert self .calc .mul (12 , 22 ) == 264
13+
14+ def test_multiple_with_one_negative (self ):
15+ assert self .calc .mul (12 , - 3 ) == - 36
16+
17+ def test_multiple_with_two_negative (self ):
18+ assert self .calc .mul (- 35 , - 22 ) == 770
19+
20+ def test_type_error (self ):
21+ with pytest .raises (TypeError ):
22+ self .calc .add (3 , '6' )
Original file line number Diff line number Diff line change 1+ import math
2+ import pytest
3+
4+ import calculator
5+
6+
7+ class TestRemClass :
8+ calc = calculator .Calculator ()
9+
10+ def test_rem_with_zero (self ):
11+ with pytest .raises (ZeroDivisionError ):
12+ self .calc .div (24 , 0 )
13+
14+ def test_rem (self ):
15+ assert self .calc .rem (13 , 5 ) == 3
16+
17+ def test_rem_with_one_negative (self ):
18+ assert self .calc .rem (- 13 , 5 ) == - 13 - (math .floor ((- 13 / 5 )) * 5 )
19+
20+ def test_rem_with_two_negative (self ):
21+ assert self .calc .rem (- 35 , - 5 ) == - 35 - math .floor (- 35 / - 5 ) * - 5
22+
23+ def test_type_error (self ):
24+ with pytest .raises (TypeError ):
25+ self .calc .add (3 , '6' )
Original file line number Diff line number Diff line change 1+ import pytest
2+ import calculator
3+
4+
5+ class TestSubClass :
6+ calc = calculator .Calculator ()
7+
8+ def test_sub (self ):
9+ assert self .calc .sub (3 , 5 ) == - 2
10+
11+ def test_sub_with_one_negative (self ):
12+ assert self .calc .sub (- 5 , 5 ) == - 10
13+
14+ def test_sub_with_two_negative (self ):
15+ assert self .calc .sub (- 5 , - 5 ) == 0
16+
17+ def test_type_error (self ):
18+ with pytest .raises (TypeError ):
19+ self .calc .add (3 , '6' )
You can’t perform that action at this time.
0 commit comments