def lgtm(message: str, keyword: str) -> None: """画像のURL・パス・キーワードを指定して画像を取得してLGTMを行う関数。 Args: message (str): 画像に描画するメッセージ keyword (str): 画像を取得するURL, ローカルパス, キーワード """ fp = get_image(keyword) save_with_message(fp, message)
def lgtm(keyword, message): with get_image(keyword) as fp: save_with_message(fp, message)
def lgtm(keyword, message): # ファイルオブジェクトはコンテキストマネージャ with get_image(keyword) as fp: save_with_message(fp, message)
def lgtm(keyword, message): # ここにロジックを追加していく with get_image(keyword) as fp: save_with_message(fp, message)
def test_get_image(self): keyword = 'book' file = image_source.get_image(keyword) self.assertTrue(isinstance(file, io.BytesIO))
def test_get_image(self): from lgtm.image_source import get_image with patch("lgtm.image_source.ImageSource") as mock: get_image("dog") mock.assert_called_once_with("dog")
def lgtm(keyword: str, message: str) -> None: with get_image(keyword) as fp: save_with_message(fp, message)