From 34655efc33d305b445fd175a081ca298cb9f3fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20M=C3=BCller?= <mueller.seb@posteo.de> Date: Thu, 27 Feb 2025 10:35:48 +0100 Subject: [PATCH] tests: make pint test for dimensionless safe --- tests/data/test_cf_units.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/data/test_cf_units.py b/tests/data/test_cf_units.py index c6e5404f..8ad8833d 100644 --- a/tests/data/test_cf_units.py +++ b/tests/data/test_cf_units.py @@ -23,9 +23,11 @@ class TestCfUnits(unittest.TestCase): self.assertEqual(u("degC"), "°C") self.assertEqual(u("degree_Celsius"), "°C") - self.assertEqual(u(""), "1") - self.assertEqual(u("1"), "1") - self.assertEqual(u("m/m"), "1") + # "dimensionless" representation inconsistent across different pint versions + # will be "1" for newer versions (>=0.24.1) to be in line with cf-conventions + self.assertTrue(u("") in ("1", "dimensionless", "")) + self.assertTrue(u("1") in ("1", "dimensionless", "")) + self.assertTrue(u("m/m") in ("1", "dimensionless", "")) self.assertEqual(u("m/s"), "m s-1") self.assertEqual(u("m s-1"), "m s-1") -- GitLab