def test(self, mock_open): image = mock_open.return_value image.size = (400, 300) img = i.Py4kaImage(MagicMock()) self.assertEqual(img.font_size, 30)
def test_using_round(self, mock_open): image = mock_open.return_value image.size = (400, 305) img = i.Py4kaImage(MagicMock()) # round(30.5)は30となる仕様 self.assertEqual(img.font_size, 30)
def test(self, mock_open): image = mock_open.return_value image_path = MagicMock() img = i.Py4kaImage(image_path) save_name = MagicMock() img.save(save_name) self.assertEqual([call(save_name)], image.save.call_args_list)
def test(self, mock_open): image = mock_open.return_value image.size = (300, 400) image_path = MagicMock() img = i.Py4kaImage(image_path) message = 'Hello' x, y = img._start_coordinate_of_text(message) font_size = round(0.1*400) self.assertEqual(round((300-(0.5*font_size*len('Hello')))/2), x) self.assertEqual(round((400-font_size)/2), y)
def test_draw_set(self, start_coordinate_of_text, load_font, mock_open): start_coordinate = start_coordinate_of_text.return_value font = load_font.return_value image_path = MagicMock() img = i.Py4kaImage(image_path) message = MagicMock() img.write(message) self.assertEqual([call(img)], load_font.call_args_list) self.assertEqual( [call(message)], start_coordinate_of_text.call_args_list) self.assertEqual( [call(start_coordinate, message, font=font, fill='gray')], img.draw.text.call_args_list)