def test_command_save(self): xkcd.sel_comic = 1000 xkcd.command_save("1000.png") with open("1000.png", "rb") as saved_image: content = saved_image.read() try: with open("1000_correct.png", "rb") as correct_image: correct_content = correct_image.read() except IOError: with open("tests/1000_correct.png", "rb") as correct_image: correct_content = correct_image.read() self.assertEqual(content, correct_content) shutil.rmtree(xkcd.tmpimg_location) os.remove("1000.png")
def test_command_save_404(self): xkcd.sel_comic = 1608 output = xkcd.command_save() excepted_output = "No image for comic found (maybe it's interactive?)" self.assertEqual(output, excepted_output)