def test_paragraph_when_invalid_align_is_passed(self): try: Html.paragraph(text=self.text, align='') except KeyError: return self.fail()
def test_image_align_center(self): html_image = '<img src="{}" />'.format(self.path) expected_image = "<p align=\"{}\">\n {}\n</p>".format( "center", html_image) actual_image = Html.image(path=self.path, align='center') self.assertEqual(expected_image, actual_image)
def test_image_size_width_height(self): size = '200' expected_image = '<img src="{}" width="{}" height="{}"/>'.format( self.path, size, size) actual_image = Html.image(path=self.path, size='200x200') self.assertEqual(expected_image, actual_image)
def test_image_align_center_width_height(self): size = '200' html_image = '<img src="{}" width="{}" height="{}"/>'.format( self.path, size, size) expected_image = "<p align=\"{}\">\n {}\n</p>".format( "center", html_image) actual_image = Html.image(path=self.path, size='200x200', align='center') self.assertEqual(expected_image, actual_image)
def test_image_size_height(self): expected_image = '<img src="{}" height="200"/>'.format(self.path) actual_image = Html.image(path=self.path, size='x200') self.assertEqual(expected_image, actual_image)
def test_image_path(self): expected_image = '<img src="{}" />'.format(self.path) actual_image = Html.image(path=self.path) self.assertEqual(expected_image, actual_image)
def test_paragraph_when_align_is_not_defined(self): expected_paragraph = "<p>\n {}\n</p>".format(self.text) actual_paragraph = Html.paragraph(text=self.text) self.assertEqual(expected_paragraph, actual_paragraph)
def test_paragraph(self): expected_paragraph = "<p align=\"{}\">\n {}\n</p>".format( "left", self.text) actual_paragraph = Html.paragraph(text=self.text, align="left") self.assertEqual(expected_paragraph, actual_paragraph)
op = input("\nEnter output image path: ") while (j > 0): if os.path.isfile(op): j = -1 else: print("\nPlease enter correct path or filename.\n") op = input("\nEnter correct output image path: ") j += 1 mdFile.new_header(level=2, title="**{}. {}**".format(i + 1, ques), add_table_of_contents='n') mdFile.insert_code(code, lang) mdFile.new_line("<br>\n\n") mdFile.new_header(level=3, title="**Output:**\n<br>", add_table_of_contents='n') imgPath = r'{}'.format(op) im = Image.open(imgPath) w, h = im.size if w > 573: w = 573 im.close() mdFile.new_paragraph(Html.image(path=imgPath, size="{}".format(w))) mdFile.new_line("<div class=\"page\"/>\n\n") mdFile.create_md_file() print("\nCreated md file at {}\{}.md".format(pathlib.Path().absolute(), fn)) print("\nOpening VS Code.\n") os.popen("code {}.md".format(fn))