comparison MoinMoin/converter/_tests/test_include.py @ 1014:d966ee4fba91

test for issue #80 (circular transclusion)
author "Luis Henrique Fagundes <lhfagundes@gmail.com>"
date Fri, 28 Oct 2011 19:51:22 -0200
parents beabd93b3904
children dfbe65482a03
comparison
equal deleted inserted replaced
998:76108d59b0f7 1014:d966ee4fba91
7 7
8 8
9 import pytest 9 import pytest
10 10
11 from MoinMoin.converter.include import * 11 from MoinMoin.converter.include import *
12 from MoinMoin.items import MoinWiki
13 from MoinMoin.config import CONTENTTYPE
14 from MoinMoin._tests import wikiconfig, update_item
12 15
13 def test_XPointer(): 16 class TestInclude(object):
14 x = XPointer('a') 17 class Config(wikiconfig.Config):
15 assert len(x) == 1 18 """
16 e = x[0] 19 we just have this so the test framework creates a new app with empty backends for us.
17 assert e.name == 'a' 20 """
18 assert e.data is None
19 21
20 x = XPointer('a(b)') 22 def test_XPointer(self):
21 assert len(x) == 1 23 x = XPointer('a')
22 e = x[0] 24 assert len(x) == 1
23 assert e.name == 'a' 25 e = x[0]
24 assert e.data == 'b' 26 assert e.name == 'a'
27 assert e.data is None
25 28
26 x = XPointer('a(^(b^)^^)') 29 x = XPointer('a(b)')
27 assert len(x) == 1 30 assert len(x) == 1
28 e = x[0] 31 e = x[0]
29 assert e.name == 'a' 32 assert e.name == 'a'
30 assert e.data == '^(b^)^^' 33 assert e.data == 'b'
31 assert e.data_unescape == '(b)^'
32 34
33 x = XPointer('a(b)c(d)') 35 x = XPointer('a(^(b^)^^)')
34 assert len(x) == 2 36 assert len(x) == 1
35 e = x[0] 37 e = x[0]
36 assert e.name == 'a' 38 assert e.name == 'a'
37 assert e.data == 'b' 39 assert e.data == '^(b^)^^'
38 e = x[1] 40 assert e.data_unescape == '(b)^'
39 assert e.name == 'c'
40 assert e.data == 'd'
41 41
42 x = XPointer('a(b) c(d)') 42 x = XPointer('a(b)c(d)')
43 assert len(x) == 2 43 assert len(x) == 2
44 e = x[0] 44 e = x[0]
45 assert e.name == 'a' 45 assert e.name == 'a'
46 assert e.data == 'b' 46 assert e.data == 'b'
47 e = x[1] 47 e = x[1]
48 assert e.name == 'c' 48 assert e.name == 'c'
49 assert e.data == 'd' 49 assert e.data == 'd'
50 50
51 x = XPointer('a(a(b))') 51 x = XPointer('a(b) c(d)')
52 assert len(x) == 1 52 assert len(x) == 2
53 e = x[0] 53 e = x[0]
54 assert e.name == 'a' 54 assert e.name == 'a'
55 assert e.data == 'a(b)' 55 assert e.data == 'b'
56 e = x[1]
57 assert e.name == 'c'
58 assert e.data == 'd'
56 59
60 x = XPointer('a(a(b))')
61 assert len(x) == 1
62 e = x[0]
63 assert e.name == 'a'
64 assert e.data == 'a(b)'
65
66 def test_IncludeHandlesCircularRecursion(self):
67 # issue #80
68 # we choosed MoinWiki items so tests get simpler
69 update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{page2}}')
70 update_item(u'page2', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{page3}}')
71 update_item(u'page3', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{page1}}')
72
73 page1 = MoinWiki.create(u'page1')
74
75 page1._render_data()