From 7bdda2e2a64c13c91568287c583198affef67717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 3 Nov 2020 09:05:41 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20Rewrite=20unit=20test=20to=20wor?= =?UTF-8?q?k=20in=20py=202&3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/util/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/octoprint/util/__init__.py b/src/octoprint/util/__init__.py index 697118d22..bfd64be45 100644 --- a/src/octoprint/util/__init__.py +++ b/src/octoprint/util/__init__.py @@ -961,8 +961,11 @@ def dict_flatten(dictionary, prefix="", separator="."): Example:: >>> data = {'a': {'a1': 'a1', 'a2': 'a2'}, 'b': 'b'} - >>> dict_flatten(data) - dict(a.a1='a1', a.a2='a2', b='b') + >>> expected = {'a.a1': 'a1', 'a.a2': 'a2', 'b': 'b'} + >>> actual = dict_flatten(data) + >>> shared = {(k, actual[k]) for k in actual if k in expected and actual[k] == expected[k]} + >>> len(shared) == len(expected) + True Args: dictionary: the dictionary to flatten