(self)
| 19 | |
| 20 | class TestRecursion(TestCase): |
| 21 | def test_listrecursion(self): |
| 22 | x = [] |
| 23 | x.append(x) |
| 24 | try: |
| 25 | json.dumps(x) |
| 26 | except ValueError: |
| 27 | pass |
| 28 | else: |
| 29 | self.fail("didn't raise ValueError on list recursion") |
| 30 | x = [] |
| 31 | y = [x] |
| 32 | x.append(y) |
| 33 | try: |
| 34 | json.dumps(x) |
| 35 | except ValueError: |
| 36 | pass |
| 37 | else: |
| 38 | self.fail("didn't raise ValueError on alternating list recursion") |
| 39 | y = [] |
| 40 | x = [y, y] |
| 41 | # ensure that the marker is cleared |
| 42 | json.dumps(x) |
| 43 | |
| 44 | def test_dictrecursion(self): |
| 45 | x = {} |