summaryrefslogtreecommitdiff
path: root/pint/testsuite/test_quantity.py
diff options
context:
space:
mode:
authorClark Willison <clarkgwillison@gmail.com>2020-06-05 17:54:30 -0700
committerClark Willison <clarkgwillison@gmail.com>2020-06-08 11:10:04 -0700
commit6aea23aa303b6f4c470eb1c923e91da7b7c09581 (patch)
treedae3c6149184c162de33f27ab6bdc46956df52a2 /pint/testsuite/test_quantity.py
parentac79c0606ef57bf07dac30c276d00219b36ee604 (diff)
downloadpint-6aea23aa303b6f4c470eb1c923e91da7b7c09581.tar.gz
fix superscripting in HTML and pretty print
HTML formatting only superscripted the first character of the exponent without brackets around it this commit brackets the base and exponent to fix this rendering issue this commit also improves pretty printing of exponents by using the unicode dot operator instead of a period tests updated to expect the brackets, black and flake8 run
Diffstat (limited to 'pint/testsuite/test_quantity.py')
-rw-r--r--pint/testsuite/test_quantity.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/pint/testsuite/test_quantity.py b/pint/testsuite/test_quantity.py
index b58e227..fa18fe8 100644
--- a/pint/testsuite/test_quantity.py
+++ b/pint/testsuite/test_quantity.py
@@ -134,7 +134,7 @@ class TestQuantity(QuantityTestCase):
r"4.12345678\ \frac{\mathrm{kilogram} \cdot \mathrm{meter}^{2}}{\mathrm{second}}",
),
("{:P}", "4.12345678 kilogram·meter²/second"),
- ("{:H}", r"\[4.12345678\ kilogram\ meter^2/second\]"),
+ ("{:H}", r"\[4.12345678\ kilogram\ {meter}^{2}/second\]"),
("{:C}", "4.12345678 kilogram*meter**2/second"),
("{:~}", "4.12345678 kg * m ** 2 / s"),
(
@@ -142,7 +142,7 @@ class TestQuantity(QuantityTestCase):
r"4.12345678\ \frac{\mathrm{kg} \cdot \mathrm{m}^{2}}{\mathrm{s}}",
),
("{:P~}", "4.12345678 kg·m²/s"),
- ("{:H~}", r"\[4.12345678\ kg\ m^2/s\]"),
+ ("{:H~}", r"\[4.12345678\ kg\ {m}^{2}/s\]"),
("{:C~}", "4.12345678 kg*m**2/s"),
("{:Lx}", r"\SI[]{4.12345678}{\kilo\gram\meter\squared\per\second}"),
):
@@ -209,12 +209,12 @@ class TestQuantity(QuantityTestCase):
r"4.12345678\ \frac{\mathrm{kilogram} \cdot \mathrm{meter}^{2}}{\mathrm{second}}",
),
("P", "4.12345678 kilogram·meter²/second"),
- ("H", r"\[4.12345678\ kilogram\ meter^2/second\]"),
+ ("H", r"\[4.12345678\ kilogram\ {meter}^{2}/second\]"),
("C", "4.12345678 kilogram*meter**2/second"),
("~", "4.12345678 kg * m ** 2 / s"),
("L~", r"4.12345678\ \frac{\mathrm{kg} \cdot \mathrm{m}^{2}}{\mathrm{s}}"),
("P~", "4.12345678 kg·m²/s"),
- ("H~", r"\[4.12345678\ kg\ m^2/s\]"),
+ ("H~", r"\[4.12345678\ kg\ {m}^{2}/s\]"),
("C~", "4.12345678 kg*m**2/s"),
):
with self.subTest(spec):
@@ -250,7 +250,7 @@ class TestQuantity(QuantityTestCase):
ureg = UnitRegistry()
x = 3.5 * ureg.Unit(UnitsContainer(meter=2, kilogram=1, second=-1))
- self.assertEqual(x._repr_html_(), r"\[3.5\ kilogram\ meter^2/second\]")
+ self.assertEqual(x._repr_html_(), r"\[3.5\ kilogram\ {meter}^{2}/second\]")
self.assertEqual(
x._repr_latex_(),
r"$3.5\ \frac{\mathrm{kilogram} \cdot "
@@ -259,7 +259,7 @@ class TestQuantity(QuantityTestCase):
x._repr_pretty_(Pretty, False)
self.assertEqual("".join(alltext), "3.5 kilogram·meter²/second")
ureg.default_format = "~"
- self.assertEqual(x._repr_html_(), r"\[3.5\ kg\ m^2/s\]")
+ self.assertEqual(x._repr_html_(), r"\[3.5\ kg\ {m}^{2}/s\]")
self.assertEqual(
x._repr_latex_(),
r"$3.5\ \frac{\mathrm{kg} \cdot " r"\mathrm{m}^{2}}{\mathrm{s}}$",