diff options
author | Hernan Grecco <hgrecco@gmail.com> | 2023-04-29 19:44:20 -0300 |
---|---|---|
committer | Hernan Grecco <hgrecco@gmail.com> | 2023-04-29 19:44:20 -0300 |
commit | b63697287ba1e5de7300890ea4c03b8781b04863 (patch) | |
tree | 0eb5db03beef71ddfb5a094521034b9f0b212b5b /pint/testsuite | |
parent | 10f69c4870ef9acda1b5dd21f2bf87f15855d3ea (diff) | |
download | pint-b63697287ba1e5de7300890ea4c03b8781b04863.tar.gz |
Run pyupgrade --py39-plus in all files except _vendor
Diffstat (limited to 'pint/testsuite')
-rw-r--r-- | pint/testsuite/test_babel.py | 6 | ||||
-rw-r--r-- | pint/testsuite/test_compat_upcast.py | 4 | ||||
-rw-r--r-- | pint/testsuite/test_contexts.py | 4 | ||||
-rw-r--r-- | pint/testsuite/test_issues.py | 4 | ||||
-rw-r--r-- | pint/testsuite/test_measurement.py | 2 | ||||
-rw-r--r-- | pint/testsuite/test_non_int.py | 8 | ||||
-rw-r--r-- | pint/testsuite/test_quantity.py | 8 | ||||
-rw-r--r-- | pint/testsuite/test_umath.py | 6 | ||||
-rw-r--r-- | pint/testsuite/test_unit.py | 2 | ||||
-rw-r--r-- | pint/testsuite/test_util.py | 4 |
10 files changed, 23 insertions, 25 deletions
diff --git a/pint/testsuite/test_babel.py b/pint/testsuite/test_babel.py index 5c32879..7842d54 100644 --- a/pint/testsuite/test_babel.py +++ b/pint/testsuite/test_babel.py @@ -84,16 +84,16 @@ def test_str(func_registry): s = "24.0 meter" assert str(d) == s assert "%s" % d == s - assert "{}".format(d) == s + assert f"{d}" == s ureg.set_fmt_locale("fr_FR") s = "24.0 mètres" assert str(d) == s assert "%s" % d == s - assert "{}".format(d) == s + assert f"{d}" == s ureg.set_fmt_locale(None) s = "24.0 meter" assert str(d) == s assert "%s" % d == s - assert "{}".format(d) == s + assert f"{d}" == s diff --git a/pint/testsuite/test_compat_upcast.py b/pint/testsuite/test_compat_upcast.py index ad267c1..56996b9 100644 --- a/pint/testsuite/test_compat_upcast.py +++ b/pint/testsuite/test_compat_upcast.py @@ -126,9 +126,7 @@ def test_array_function_deferral(da, module_registry): upper = 3 * module_registry.m args = (da, lower, upper) assert ( - lower.__array_function__( - np.clip, tuple(set(type(arg) for arg in args)), args, {} - ) + lower.__array_function__(np.clip, tuple({type(arg) for arg in args}), args, {}) is NotImplemented ) diff --git a/pint/testsuite/test_contexts.py b/pint/testsuite/test_contexts.py index c7551e4..ea6525d 100644 --- a/pint/testsuite/test_contexts.py +++ b/pint/testsuite/test_contexts.py @@ -683,7 +683,7 @@ class TestDefinedContexts: ) p = find_shortest_path(ureg._active_ctx.graph, da, db) assert p - msg = "{} <-> {}".format(a, b) + msg = f"{a} <-> {b}" # assertAlmostEqualRelError converts second to first helpers.assert_quantity_almost_equal(b, a, rtol=0.01, msg=msg) @@ -705,7 +705,7 @@ class TestDefinedContexts: da, db = Context.__keytransform__(a.dimensionality, b.dimensionality) p = find_shortest_path(ureg._active_ctx.graph, da, db) assert p - msg = "{} <-> {}".format(a, b) + msg = f"{a} <-> {b}" helpers.assert_quantity_almost_equal(b, a, rtol=0.01, msg=msg) # Check RKM <-> cN/tex conversion diff --git a/pint/testsuite/test_issues.py b/pint/testsuite/test_issues.py index 8517bd9..9540814 100644 --- a/pint/testsuite/test_issues.py +++ b/pint/testsuite/test_issues.py @@ -445,10 +445,10 @@ class TestIssues(QuantityTestCase): def test_issue354_356_370(self, module_registry): assert ( - "{:~}".format(1 * module_registry.second / module_registry.millisecond) + f"{1 * module_registry.second / module_registry.millisecond:~}" == "1.0 s / ms" ) - assert "{:~}".format(1 * module_registry.count) == "1 count" + assert f"{1 * module_registry.count:~}" == "1 count" assert "{:~}".format(1 * module_registry("MiB")) == "1 MiB" def test_issue468(self, module_registry): diff --git a/pint/testsuite/test_measurement.py b/pint/testsuite/test_measurement.py index b78ca0e..9de2762 100644 --- a/pint/testsuite/test_measurement.py +++ b/pint/testsuite/test_measurement.py @@ -178,7 +178,7 @@ class TestMeasurement(QuantityTestCase): ): with subtests.test(spec): self.ureg.default_format = spec - assert "{}".format(m) == result + assert f"{m}" == result def test_raise_build(self): v, u = self.Q_(1.0, "s"), self.Q_(0.1, "s") diff --git a/pint/testsuite/test_non_int.py b/pint/testsuite/test_non_int.py index 66637e1..d0b27ae 100644 --- a/pint/testsuite/test_non_int.py +++ b/pint/testsuite/test_non_int.py @@ -740,10 +740,10 @@ class _TestQuantityBasicMath(NonIntTypeTestCase): zy = self.Q_(fun(y.magnitude), "meter") rx = fun(x) ry = fun(y) - assert rx == zx, "while testing {0}".format(fun) - assert ry == zy, "while testing {0}".format(fun) - assert rx is not zx, "while testing {0}".format(fun) - assert ry is not zy, "while testing {0}".format(fun) + assert rx == zx, f"while testing {fun}" + assert ry == zy, f"while testing {fun}" + assert rx is not zx, f"while testing {fun}" + assert ry is not zy, f"while testing {fun}" def test_quantity_float_complex(self): x = self.QP_("-4.2", None) diff --git a/pint/testsuite/test_quantity.py b/pint/testsuite/test_quantity.py index 8fb712a..18a56ab 100644 --- a/pint/testsuite/test_quantity.py +++ b/pint/testsuite/test_quantity.py @@ -1050,10 +1050,10 @@ class TestQuantityBasicMath(QuantityTestCase): zy = self.Q_(fun(y.magnitude), "meter") rx = fun(x) ry = fun(y) - assert rx == zx, "while testing {0}".format(fun) - assert ry == zy, "while testing {0}".format(fun) - assert rx is not zx, "while testing {0}".format(fun) - assert ry is not zy, "while testing {0}".format(fun) + assert rx == zx, f"while testing {fun}" + assert ry == zy, f"while testing {fun}" + assert rx is not zx, f"while testing {fun}" + assert ry is not zy, f"while testing {fun}" def test_quantity_float_complex(self): x = self.Q_(-4.2, None) diff --git a/pint/testsuite/test_umath.py b/pint/testsuite/test_umath.py index 6f32ab5..73d0ae7 100644 --- a/pint/testsuite/test_umath.py +++ b/pint/testsuite/test_umath.py @@ -79,7 +79,7 @@ class TestUFuncs: if results is None: results = [None] * len(ok_with) for x1, res in zip(ok_with, results): - err_msg = "At {} with {}".format(func.__name__, x1) + err_msg = f"At {func.__name__} with {x1}" if output_units == "same": ou = x1.units elif isinstance(output_units, (int, float)): @@ -163,7 +163,7 @@ class TestUFuncs: if results is None: results = [None] * len(ok_with) for x1, res in zip(ok_with, results): - err_msg = "At {} with {}".format(func.__name__, x1) + err_msg = f"At {func.__name__} with {x1}" qms = func(x1) if res is None: res = func(x1.magnitude) @@ -223,7 +223,7 @@ class TestUFuncs: """ for x2 in ok_with: - err_msg = "At {} with {} and {}".format(func.__name__, x1, x2) + err_msg = f"At {func.__name__} with {x1} and {x2}" if output_units == "same": ou = x1.units elif output_units == "prod": diff --git a/pint/testsuite/test_unit.py b/pint/testsuite/test_unit.py index 98a4fcc..fcfb2ed 100644 --- a/pint/testsuite/test_unit.py +++ b/pint/testsuite/test_unit.py @@ -144,7 +144,7 @@ class TestUnit(QuantityTestCase): ureg = UnitRegistry() - assert "{:new}".format(ureg.m) == "new format" + assert f"{ureg.m:new}" == "new format" def test_ipython(self): alltext = [] diff --git a/pint/testsuite/test_util.py b/pint/testsuite/test_util.py index bfbc55d..82cda7a 100644 --- a/pint/testsuite/test_util.py +++ b/pint/testsuite/test_util.py @@ -353,12 +353,12 @@ class TestOtherUtils: # Test with list, string, generator, and scalar assert iterable([0, 1, 2, 3]) assert iterable("test") - assert iterable((i for i in range(5))) + assert iterable(i for i in range(5)) assert not iterable(0) def test_sized(self): # Test with list, string, generator, and scalar assert sized([0, 1, 2, 3]) assert sized("test") - assert not sized((i for i in range(5))) + assert not sized(i for i in range(5)) assert not sized(0) |