summaryrefslogtreecommitdiff
path: root/pint/testsuite/test_unit.py
diff options
context:
space:
mode:
Diffstat (limited to 'pint/testsuite/test_unit.py')
-rw-r--r--pint/testsuite/test_unit.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/pint/testsuite/test_unit.py b/pint/testsuite/test_unit.py
index 992551c..e6ce581 100644
--- a/pint/testsuite/test_unit.py
+++ b/pint/testsuite/test_unit.py
@@ -15,7 +15,7 @@ from pint import (
)
from pint.compat import np
from pint.registry import LazyRegistry, UnitRegistry
-from pint.testsuite import QuantityTestCase, helpers
+from pint.testsuite import QuantityTestCase, assert_no_warnings, helpers
from pint.util import ParserHelper, UnitsContainer
@@ -80,6 +80,18 @@ class TestUnit(QuantityTestCase):
ureg.default_format = spec
assert f"{x}" == result, f"Failed for {spec}, {result}"
+ def test_unit_formatting_defaults_warning(self):
+ ureg = UnitRegistry()
+ ureg.default_format = "~P"
+ x = ureg.Unit("m / s ** 2")
+
+ with pytest.warns(DeprecationWarning):
+ assert f"{x:.2f}" == "meter / second ** 2"
+
+ ureg.separate_format_defaults = True
+ with assert_no_warnings():
+ assert f"{x:.2f}" == "m/s²"
+
def test_unit_formatting_snake_case(self, subtests):
# Test that snake_case units are escaped where appropriate
ureg = UnitRegistry()