diff options
author | Yann Büchau <nobodyinperson@posteo.de> | 2023-02-09 11:06:30 +0100 |
---|---|---|
committer | Yann Büchau <nobodyinperson@posteo.de> | 2023-02-09 11:06:30 +0100 |
commit | 62bb350c75d4d8fa61a490eb82c8770c2a09e37b (patch) | |
tree | cd1c6a0d749c040789d172a4bad89bfe2553cd43 /pint | |
parent | f96256042b1f343ae8e0cce0ba321b5fb9b4a6b4 (diff) | |
download | pint-62bb350c75d4d8fa61a490eb82c8770c2a09e37b.tar.gz |
Add test for siunitx formatting
- works fine for %-sign, however not really for the weird characters
- what do we even want the weird characters to be in siunitx mode?
Diffstat (limited to 'pint')
-rw-r--r-- | pint/testsuite/test_unit.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pint/testsuite/test_unit.py b/pint/testsuite/test_unit.py index bb6f7ea..402556c 100644 --- a/pint/testsuite/test_unit.py +++ b/pint/testsuite/test_unit.py @@ -58,7 +58,12 @@ class TestUnit(QuantityTestCase): ureg = UnitRegistry() ureg.define(r"percent = 1e-2 = %") x = ureg.Unit(UnitsContainer(percent=1)) - for spec, result in {"L": r"\mathrm{percent}", "L~": r"\mathrm{\%}"}.items(): + for spec, result in { + "L": r"\mathrm{percent}", + "L~": r"\mathrm{\%}", + "Lx": r"\si[]{\percent}", + "Lx~": r"\si[]{\%}", + }.items(): with subtests.test(spec): ureg.default_format = spec assert f"{x}" == result, f"Failed for {spec}, {result}" @@ -68,6 +73,9 @@ class TestUnit(QuantityTestCase): for spec, result in { "L": r"\mathrm{weirdunit}", "L~": r"\mathrm{\textbackslash \textasciitilde \_\textasciicircum \&\%\$\_\{\}}", + "Lx": r"\si[]{\weirdunit}", + # TODO: Currently makes \si[]{\\~_^&%$_{}} (broken). What do we even want this to be? + # "Lx~": r"\si[]{\textbackslash \textasciitilde \_\textasciicircum \&\%\$\_\{\}}", }.items(): with subtests.test(spec): ureg.default_format = spec |