From 8ded99f2372f612c02dd4d47cb7a30200fdafd72 Mon Sep 17 00:00:00 2001 From: PGijsbers Date: Thu, 26 Sep 2024 21:47:36 +0200 Subject: [PATCH] Make test insensitive to OrderedDict stringification Sometime between 3.9 and 3.12 the stringification of ordered dicts changed from using a list of tuples to a dictionary. --- tests/test_flows/test_flow_functions.py | 28 +++++++++---------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/tests/test_flows/test_flow_functions.py b/tests/test_flows/test_flow_functions.py index f9ce97c2f..b3d5be1a6 100644 --- a/tests/test_flows/test_flow_functions.py +++ b/tests/test_flows/test_flow_functions.py @@ -5,6 +5,8 @@ import functools import unittest from collections import OrderedDict +from multiprocessing.managers import Value + from packaging.version import Version from unittest import mock from unittest.mock import patch @@ -195,27 +197,17 @@ def test_are_flows_equal_ignore_parameter_values(self): new_flow = copy.deepcopy(flow) new_flow.parameters["a"] = 7 - self.assertRaisesRegex( - ValueError, - r"values for attribute 'parameters' differ: " - r"'OrderedDict\(\[\('a', 5\), \('b', 6\)\]\)'\nvs\n" - r"'OrderedDict\(\[\('a', 7\), \('b', 6\)\]\)'", - openml.flows.functions.assert_flows_equal, - flow, - new_flow, - ) + with pytest.raises(ValueError) as excinfo: + openml.flows.functions.assert_flows_equal(flow, new_flow) + assert str(paramaters) in str(excinfo.value) and str(new_flow.parameters) in str(excinfo.value) + openml.flows.functions.assert_flows_equal(flow, new_flow, ignore_parameter_values=True) del new_flow.parameters["a"] - self.assertRaisesRegex( - ValueError, - r"values for attribute 'parameters' differ: " - r"'OrderedDict\(\[\('a', 5\), \('b', 6\)\]\)'\nvs\n" - r"'OrderedDict\(\[\('b', 6\)\]\)'", - openml.flows.functions.assert_flows_equal, - flow, - new_flow, - ) + with pytest.raises(ValueError) as excinfo: + openml.flows.functions.assert_flows_equal(flow, new_flow) + assert str(paramaters) in str(excinfo.value) and str(new_flow.parameters) in str(excinfo.value) + self.assertRaisesRegex( ValueError, r"Flow Test: parameter set of flow differs from the parameters "