| Revision 142,
440 bytes
checked in by xi, 7 years ago
(diff) |
|
Add support for recursive nodes to Composer. Constructor does not support recursive objects though.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | import unittest |
|---|
| 3 | from yaml import * |
|---|
| 4 | |
|---|
| 5 | RECURSIVE = """ |
|---|
| 6 | --- &A |
|---|
| 7 | - *A: *A |
|---|
| 8 | """ |
|---|
| 9 | |
|---|
| 10 | class TestRecursive(unittest.TestCase): |
|---|
| 11 | |
|---|
| 12 | def testRecursive(self): |
|---|
| 13 | node = compose(RECURSIVE) |
|---|
| 14 | self._check(node) |
|---|
| 15 | document = serialize(node) |
|---|
| 16 | node = compose(document) |
|---|
| 17 | self._check(node) |
|---|
| 18 | |
|---|
| 19 | def _check(self, node): |
|---|
| 20 | self.failUnless(node in node.value[0].value) |
|---|
| 21 | self.failUnless(node.value[0].value[node] is node) |
|---|
| 22 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.