From 4c1d0338f4f2399de1b0a7d604768a5df3bbf62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 15 Sep 2021 17:34:06 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20basic=20tests=20for=20fast=5F?= =?UTF-8?q?deepcopy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Should handle regular dict and something that's not pickleable. --- tests/util/test_fast_deepcopy.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/util/test_fast_deepcopy.py diff --git a/tests/util/test_fast_deepcopy.py b/tests/util/test_fast_deepcopy.py new file mode 100644 index 000000000..9234c6ecf --- /dev/null +++ b/tests/util/test_fast_deepcopy.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, print_function, unicode_literals + +__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" +__copyright__ = "Copyright (C) 2021 The OctoPrint Project - Released under terms of the AGPLv3 License" + +import unittest + +import octoprint.util + + +class FastDeepcopyTest(unittest.TestCase): + def test_clean(self): + data = {"a": 1, "b": 2, "c": 3} + self.assertEqual(data, octoprint.util.fast_deepcopy(data)) + + def test_function(self): + data = {"a": 1, "b": 2, "c": 3, "f": lambda x: x + 1} + self.assertEqual(data, octoprint.util.fast_deepcopy(data))