Merge branch 'sequence_clone' of hugobranquinho/colander into pr/212
This commit is contained in:
commit
f3bf9e8578
|
@ -128,6 +128,7 @@ Contributors
|
|||
- Nando Florestan, 2014/11/27
|
||||
- Amos Latteier, 2014/11/30
|
||||
- Jimmy Thrasibule, 2014/12/11
|
||||
- Hugo Branquinho, 2015/01/21
|
||||
- Daniel Dourvaris, 2015/03/04
|
||||
- Dmitry Bogun, 2015/09/10
|
||||
- Tinne Cahy, 2015/12/22
|
||||
|
|
|
@ -2116,9 +2116,12 @@ class _SchemaNode(object):
|
|||
""" Clone the schema node and return the clone. All subnodes
|
||||
are also cloned recursively. Attributes present in node
|
||||
dictionaries are preserved."""
|
||||
cloned = self.__class__(self.typ)
|
||||
cloned.__dict__.update(self.__dict__)
|
||||
cloned.children = [ node.clone() for node in self.children ]
|
||||
children = [node.clone() for node in self.children]
|
||||
cloned = self.__class__(self.typ, *children)
|
||||
|
||||
attributes = self.__dict__.copy()
|
||||
attributes.pop('children', None)
|
||||
cloned.__dict__.update(attributes)
|
||||
return cloned
|
||||
|
||||
def bind(self, **kw):
|
||||
|
|
|
@ -3423,6 +3423,13 @@ class TestSequenceSchema(unittest.TestCase):
|
|||
result = node.serialize([colander.null])
|
||||
self.assertEqual(result, [])
|
||||
|
||||
def test_clone(self):
|
||||
import colander
|
||||
thingnode = colander.SchemaNode(colander.String())
|
||||
thingnode2 = colander.SchemaNode(colander.String())
|
||||
schema = colander.SequenceSchema(colander.Sequence(), thingnode, thingnode2)
|
||||
schema.clone()
|
||||
|
||||
class TestTupleSchema(unittest.TestCase):
|
||||
def test_it(self):
|
||||
import colander
|
||||
|
|
Loading…
Reference in New Issue