From ddf0002bb760e5f1df664a81bd2a554c522f2c0f Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Mon, 20 Sep 2021 23:34:24 +0100 Subject: Refs #32948 -- Renamed Node._new_instance() to Node.create(). Node._new_instance() was added in 6dd2b5468fa275d53aa60fdcaff8c28bdc5e9c25 to work around Q.__init__() having an incompatible signature with Node.__init__(). It was intended as a hook that could be overridden if subclasses needed to change the behaviour of instantiation of their specialised form of Node. In practice this doesn't ever seem to have been used for this purpose and there are very few calls to Node._new_instance() with other code, e.g. Node.__deepcopy__() calling Node and overriding __class__ as required. Rename this to Node.create() to make it a more "official" piece of private API that we can use to simplify a lot of other areas internally. The docstring and nearby comment have been reworded to read more clearly. --- tests/utils_tests/test_tree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/utils_tests') diff --git a/tests/utils_tests/test_tree.py b/tests/utils_tests/test_tree.py index 81002e68c9..04223964ba 100644 --- a/tests/utils_tests/test_tree.py +++ b/tests/utils_tests/test_tree.py @@ -69,11 +69,11 @@ class NodeTests(unittest.TestCase): self.node1.negate() self.assertFalse(self.node1.negated) - def test_new_instance(self): + def test_create(self): SubNode = type("SubNode", (Node,), {}) a = SubNode([SubNode(["a", "b"], OR), "c"], AND) - b = SubNode._new_instance(a.children, a.connector, a.negated) + b = SubNode.create(a.children, a.connector, a.negated) self.assertEqual(a, b) # Children lists are the same object, but equal. self.assertIsNot(a.children, b.children) -- cgit v1.3