-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_unnamed.py
31 lines (23 loc) · 1.31 KB
/
test_unnamed.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
import unittest
import unnamed as clothes
class TestClothingClass(unittest.TestCase):
def setUp(self):
self.clothing = clothes.Clothing('orange', 'M', 'stripes', 35)
self.blouse = clothes.Blouse('blue', 'M', 'luxury', 40, 'Brazil')
self.pants = clothes.Pants('black', 32, 'baggy', 60, 30)
def test_initialization(self):
self.assertEqual(self.clothing.color, 'orange', 'color should be orange')
self.assertEqual(self.clothing.price, 35, 'incorrect price')
self.assertEqual(self.blouse.color, 'blue', 'color should be blue')
self.assertEqual(self.blouse.size, 'M', 'incorrect size')
self.assertEqual(self.blouse.style, 'luxury', 'incorrect style')
self.assertEqual(self.blouse.price, 40, 'incorrect price')
self.assertEqual(self.blouse.country_of_origin, 'Brazil', 'incorrect country of origin')
def test_calculateshipping(self):
self.assertEqual(self.clothing.calculate_shipping(.5, 3), .5 * 3, \
'Clothing shipping calculation not as expected')
self.assertEqual(self.blouse.calculate_shipping(.5, 3), .5 * 3, \
'Clothing shipping calculation not as expected')
tests = TestClothingClass()
tests_loaded = unittest.TestLoader().loadTestsFromModule(tests)
unittest.TextTestRunner().run(tests_loaded)