Skip to content

Commit

Permalink
Make test insensitive to OrderedDict stringification (#1353)
Browse files Browse the repository at this point in the history
Sometime between 3.9 and 3.12 the stringification of
ordered dicts changed from using a list of tuples to
a dictionary.
  • Loading branch information
PGijsbers authored Sep 27, 2024
1 parent 07e9b9c commit 7764ddb
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions tests/test_flows/test_flow_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "
Expand Down

0 comments on commit 7764ddb

Please sign in to comment.