50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
import mistletoe
|
||
import pytest
|
||
|
||
from renderer.fifty_ohm_html_renderer import FiftyOhmHtmlRenderer
|
||
|
||
from .util import paragraph
|
||
|
||
|
||
@pytest.mark.html
|
||
def test_basic_units_html():
|
||
"""Test basic units: Insert non-breaking, smaller space."""
|
||
assertions = {
|
||
"1 V": "1 V",
|
||
"0,12 V": "0,12 V",
|
||
"0,75 kW": "0,75 kW",
|
||
"33 A": "33 A",
|
||
"1 Ah": "1 Ah",
|
||
"10 A/mm²": "10 A/mm²",
|
||
"DL9MJ": "DL9MJ", # Ensure other strings, like callsings, aren‘t mistaken for units. ;)
|
||
"Ein Satz mit 200 V.": "Ein Satz mit 200 V.", # Support units before sentence ends.
|
||
}
|
||
|
||
for input, output in assertions.items():
|
||
assert mistletoe.markdown(input, FiftyOhmHtmlRenderer) == paragraph(output)
|
||
|
||
|
||
@pytest.mark.html
|
||
def test_translated_units_html():
|
||
"""Test translated units: Replace Ohm with Ω."""
|
||
assertions = {
|
||
"50 Ohm": "50 Ω",
|
||
"100 mOhm": "100 mΩ",
|
||
}
|
||
|
||
for input, output in assertions.items():
|
||
assert mistletoe.markdown(input, FiftyOhmHtmlRenderer) == paragraph(output)
|
||
|
||
|
||
@pytest.mark.html
|
||
def test_special_units_html():
|
||
"""Test special units: Don't put space before ° and %."""
|
||
assertions = {
|
||
"100%": "100%",
|
||
"100 %": "100%",
|
||
"42,24°": "42,24°",
|
||
}
|
||
|
||
for input, output in assertions.items():
|
||
assert mistletoe.markdown(input, FiftyOhmHtmlRenderer) == paragraph(output)
|