From 398105b6d7eb5b810e88e6aab8fa2c2829171880 Mon Sep 17 00:00:00 2001 From: onefloid <33193059+onefloid@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:51:00 +0200 Subject: [PATCH] Fix: Suppress expected warnings to avoid a cluttered test output --- Tests/DimensionService_test.py | 10 ++++++++-- Tests/MonitoringService_test.py | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Tests/DimensionService_test.py b/Tests/DimensionService_test.py index 1de854e8..73825934 100644 --- a/Tests/DimensionService_test.py +++ b/Tests/DimensionService_test.py @@ -1,5 +1,6 @@ import configparser import unittest +import warnings from pathlib import Path from TM1py.Objects import Dimension, Hierarchy, Element @@ -179,12 +180,17 @@ def test_get_number_of_dimensions(self): def test_execute_mdx(self): mdx = "{TM1SubsetAll(" + self.dimension_name + ")}" - elements = self.tm1.dimensions.execute_mdx(self.dimension_name, mdx) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + elements = self.tm1.dimensions.execute_mdx(self.dimension_name, mdx) self.assertEqual(len(elements), 1001) mdx = "{ Tm1FilterByLevel ( {TM1SubsetAll(" + self.dimension_name + ")}, 0) }" - elements = self.tm1.dimensions.execute_mdx(self.dimension_name, mdx) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + elements = self.tm1.dimensions.execute_mdx(self.dimension_name, mdx) self.assertEqual(len(elements), 1000) + for element in elements: self.assertTrue(element.startswith("Element")) diff --git a/Tests/MonitoringService_test.py b/Tests/MonitoringService_test.py index a5b7a3df..68f7a287 100644 --- a/Tests/MonitoringService_test.py +++ b/Tests/MonitoringService_test.py @@ -1,5 +1,6 @@ import configparser import unittest +import warnings from pathlib import Path from TM1py.Services import TM1Service @@ -20,6 +21,9 @@ def setUpClass(cls): cls.config = configparser.ConfigParser() cls.config.read(Path(__file__).parent.joinpath('config.ini')) cls.tm1 = TM1Service(**cls.config['tm1srv01']) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + cls.tm1.monitoring @skip_if_version_higher_or_equal_than(version="12.0.0") def test_get_threads(self):