1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

Fixed #22531 -- Added tree.Node.__repr__ and tests for the class.

While Node class has a useful `__str__`, its `__repr__` is not that
useful. Added a `__repr__` that makes use of the current `__str__`.
This is especially useful since the more popular `Q` class inherits
`tree.Node`. Also created new tests that cover most of `Node` class
functionality.
This commit is contained in:
Moayad Mardini
2014-05-16 15:20:12 +03:00
committed by Tim Graham
parent fadc6cd1bd
commit 393ddc10a7
2 changed files with 60 additions and 0 deletions

View File

@@ -48,6 +48,9 @@ class Node(object):
return '(%s: %s)' % (self.connector, ', '.join([str(c) for c in
self.children]))
def __repr__(self):
return "<%s: %s>" % (self.__class__.__name__, self)
def __deepcopy__(self, memodict):
"""
Utility method used by copy.deepcopy().