-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCarTest.py
48 lines (39 loc) · 1.78 KB
/
CarTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from unittest import TestCase
import pytest
from Car import Car
class TestCar(TestCase):
def test_typeerror_wheels(self):
with self.assertRaises(TypeError):
car = Car('auto', '1a', 'blue')
def test_valueerror_wheels_1(self):
with self.assertRaises(ValueError):
car = Car('auto', 1, 'blue')
def test_valueerror_wheels_11(self):
with self.assertRaises(ValueError):
car = Car('auto', 11, 'blue')
def test_PYTEST_invalid_wheels_lt_2_valueError(self):
# check the actual message thrown by valueError
with pytest.raises(ValueError, match="Wheels must be 2 - 10: value passed was 1"):
carWheelsInvalidlt1 = Car('manual', 1, 'blue')
def test_PYTEST_invalid_wheels_gt_10_valueError(self):
# check the actual message thrown by valueError
with pytest.raises(ValueError, match="Wheels must be 2 - 10: value passed was 11"):
carWheelsInvalidlt1 = Car('manual', 11, 'blue')
def test_PYTEST_invalid_wheels_7(self):
# check the actual message thrown by valueError
with pytest.raises(ValueError, match="Wheels must not be 7 !!!!!"):
carWheelsInvalidlt1 = Car('manual', 7, 'blue')
def test_valid_car_wheels_float(self):
carBlue = Car('manual', 3.0, 'blue')
# print(carRed.colour)
# carRed.car_details()
self.assertEqual(carBlue.drive, 'manual')
self.assertEqual(carBlue.color, 'blue')
self.assertEqual(carBlue.wheels, 3)
def test_valid_car_wheels_int(self):
carBlue = Car('manual', 4, 'blue')
# print(carRed.colour)
# carRed.car_details()
self.assertEqual(carBlue.drive, 'manual')
self.assertEqual(carBlue.color, 'blue')
self.assertEqual(carBlue.wheels, 4)