text_style¶
- typhoon.test.reporting.tables.text_style(paragraph, bold=False, italic=False, color='black')¶
Set a string to be a paragraph with specifics HTML tags.
- Parameters:
paragraph (string) – The text to be processed by applying the HTML tags.
bold (bool) – It is False by default. If True, applies the tags
<strong> ... </strong>
on the paragraph.italic (bool) – It is False by default. If True, applies the tags
<i> ... </i>
on the paragraph.color (string) – It is “black” by default,but other values can be selected:
"blue"
,"green"
,"red"
,"orange"
,"gray"
,"purple"
,"pink"
. Also, it can be specified in a RGB style, like"rgb(96, 128, 0)"
(Olive),"rgb(0, 255, 255)"
(Cyan) and more. Check https://www.w3schools.com/colors/ to know more about HTML colors.
Examples
>>> import allure >>> from typhoon.test.reporting.tables import text_style >>> from pathlib import Path >>> html_file = str(Path(__file__).parent / 'tmp_text_style_docs.html') >>> dummy_text = [ >>> "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", >>> "Aenean commodo ligula eget dolor. Aenean massa.", >>> "Cum sociis natoque penatibus et magnis dis parturient.", >>> "Donec quam felis, ultricies nec, pellentesque eu, pretiu.", >>> "Nulla consequat massa quis enim.", >>> "Donec pede justo, fringilla vel, aliquet nec, vulputate.", >>> "In enim justo, rhoncus ut, imperdiet a, venenatis vitae.", >>> "Nullam dictum felis eu pede mollis pretium.", >>> "Integer tincidunt. Cras dapibus.", >>> "Vivamus elementum semper nisi." >>> ] >>> dummy_styled_text = [ >>> text_style(dummy_text[0], bold=False, italic=False, color="black"), >>> text_style(dummy_text[1], bold=True, italic=False, color="black"), >>> text_style(dummy_text[2], bold=False, italic=True, color="black"), >>> text_style(dummy_text[3], bold=False, italic=False, color="blue"), >>> text_style(dummy_text[4], bold=True, italic=False, color="blue"), >>> text_style(dummy_text[5], bold=False, italic=True, color="blue"), >>> text_style(dummy_text[6], bold=True, italic=True, color="blue"), >>> text_style(dummy_text[7], bold=True, italic=True, color="red"), >>> text_style(dummy_text[8], bold=True, italic=False, >>> color="rgb(96, 128, 0)"), >>> text_style(dummy_text[9], bold=False, italic=True, >>> color="rgb(0, 255, 255)") >>> ] >>> with open(html_file, 'w') as fhtml: >>> fhtml.writelines(dummy_styled_text) >>> string_list = "".join(text for text in dummy_styled_text) >>> allure.attach(string_list, "Dummy Text", >>> allure.attachment_type.HTML)