Пример #1
0
from advent_of_code.day2.gift import Gift

dimensions = open("input.txt").readlines()
gift = Gift(dimensions)
print('How many total square feet of wrapping paper should they order?')
print(gift.calculation_of_wrapping_paper())
print('How many total feet of ribbon should they order?')
print(gift.calculation_of_feet_ribbon())
Пример #2
0
 def test_one_gift(self):
     self.assertEqual(
         Gift(['2x3x4']).calculation_of_wrapping_paper(), 58)
Пример #3
0
 def test_two_gift(self):
     self.assertEqual(
         Gift(['2x3x4', '1x1x10']).calculation_of_wrapping_paper(), 101)
Пример #4
0
 def test_negative_number(self):
     self.assertRaises(
         TypeError, Gift(['-2x3x4']).calculation_of_wrapping_paper(), ['-2x3x4'])
Пример #5
0
    def test_two_dimensions(self):
        with self.assertRaises(Exception) as context:
            Gift(['2x2']).calculation_of_wrapping_paper()

        self.assertTrue('Missing parameters' in str(context.exception))
Пример #6
0
 def test_empty_list(self):
     self.assertEqual(
         Gift([]).calculation_of_wrapping_paper(), 0)
Пример #7
0
 def test_value_feet_ribbon(self):
     self.assertEqual(
         Gift(['2x3x4']).calculation_of_feet_ribbon(), 34)
Пример #8
0
 def test_value_with_line_break(self):
     self.assertEqual(
         Gift(['2x3x4\n']).calculation_of_wrapping_paper(), 58)