~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/parser/_tests/test_text_moin_wiki.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
class TestHeadings(ParserTestCase):
93
93
    """ Test various heading problems """
94
94
 
 
95
    def class_setup(self):
 
96
        """ Require show_section_numbers = 0 to workaround counter
 
97
        global state saved in request.
 
98
        """
 
99
        self.config = self.TestConfig(show_section_numbers=0)
 
100
 
 
101
    def class_teardown(self):
 
102
        del self.config
 
103
 
95
104
    def testIgnoreWhiteSpaceAroundHeadingText(self):
96
105
        """ parser.wiki: ignore white space around heading text
97
106
 
112
121
 
113
122
class TestTOC(ParserTestCase):
114
123
 
 
124
    def class_setup(self):
 
125
        """ Require show_section_numbers = 0 to workaround counter
 
126
        global state saved in request.
 
127
        """
 
128
        self.config = self.TestConfig(show_section_numbers=0)
 
129
 
 
130
    def class_teardown(self):
 
131
        del self.config
 
132
 
115
133
    def testHeadingWithWhiteSpace(self):
116
134
        """ parser.wiki: TOC links to headings with white space
117
135
 
161
179
        (u'<<DateTime(2003-03-03T03:03:03)>>',   '2003-03-03 03:03:03'),
162
180
        (u'<<DateTime(2000-01-01T00:00:00Z)>>',  '2000-01-01 00:00:00'), # works for Europe/Vilnius
163
181
        (u'<<Date(2002-02-02T01:02:03Z)>>',      '2002-02-02'),
164
 
        #(u'<<DateTime(1970-01-06T00:00:00)>>',   '1970-01-06 00:00:00'), # fails e.g. for Europe/Vilnius
 
182
        (u'<<DateTime(1970-01-06T00:00:00)>>',   '1970-01-06 00:00:00'), # fails e.g. for Europe/Vilnius
165
183
        )
166
184
 
 
185
    def class_setup(self):
 
186
        """ Require default date and time format config values """
 
187
        self.config = self.TestConfig(defaults=('date_fmt', 'datetime_fmt'))
 
188
 
 
189
    def class_teardown(self):
 
190
        del self.config
 
191
 
167
192
    def testDateTimeMacro(self):
168
193
        """ parser.wiki: DateTime macro """
169
194
        note = """
171
196
    If this fails, it is likely a problem in your python / libc,
172
197
    not in moin.  See also: <http://sourceforge.net/tracker/index.php?func=detail&aid=902172&group_id=5470&atid=105470>
173
198
 
174
 
    It can also be related to TZ changes a country historically made and then
175
 
    shows a bug in moin. For this reason, the last tuple above is commented out.
 
199
    It can also be related to TZ changes a country historically made.
176
200
    """
177
201
 
178
202
        for test, expected in self._tests:
392
416
"""
393
417
        for test, blockstart in self.cases:
394
418
            # We dont test here formatter white space generation
395
 
            expected = r'<p.*?>AAA\s*\n*(<span.*?></span>\s*\n*)?%s' % blockstart
 
419
            expected = r'<p.*?>AAA\s*\n*%s' % blockstart
396
420
            needle = re.compile(expected, re.MULTILINE)
397
421
            result = self.parse(text % test)
398
422
            print expected, result
442
466
}}}}"""
443
467
        output = self.parse(raw)
444
468
        output = ''.join(output)
445
 
        assert "{{{This is some nested text}}}" in output
 
469
        assert "r'{{{This is some nested text}}}'" in output
446
470
 
447
471
    def testNestingPreBrackets(self):
448
472
        """ tests nested {{{ }}} for the wiki parser
465
489
}}}}"""
466
490
        output = self.parse(raw)
467
491
        output = ''.join(output)
468
 
        assert re.search('Example <ul><li style="list-style-type:none"><pre><span class="anchor" id="[^"]*"></span>You can use {{{brackets}}}</pre>', output)
 
492
        assert 'Example <ul><li style="list-style-type:none"><pre>You can use {{{brackets}}}</pre>' in output
469
493
 
470
494
    def testManyNestingPreBrackets(self):
471
495
        """ tests two nestings  ({{{ }}} and {{{ }}}) in one line for the wiki parser
475
499
}}}}"""
476
500
        output = self.parse(raw)
477
501
        output = ''.join(output)
478
 
        expected = '<pre><span class="anchor" id="[^"]*"></span>Test {{{brackets}}} and test {{{brackets}}}'
479
 
        assert re.search(expected, output)
 
502
        expected = '<pre>Test {{{brackets}}} and test {{{brackets}}}'
 
503
        assert expected in output
480
504
 
481
505
    def testMultipleShortPreSections(self):
482
506
        """
494
518
    needle = re.compile(text % r'(.+)')
495
519
    _tests = [
496
520
        # test,           expected
497
 
        ('SomeNonExistentPage', '<a class="nonexistent" href="/SomeNonExistentPage">SomeNonExistentPage</a>'),
498
 
        ('SomeNonExistentPage#anchor', '<a class="nonexistent" href="/SomeNonExistentPage#anchor">SomeNonExistentPage#anchor</a>'),
499
 
        ('[[something]]', '<a class="nonexistent" href="/something">something</a>'),
500
 
        ('[[some thing]]', '<a class="nonexistent" href="/some%20thing">some thing</a>'),
501
 
        ('[[something|some text]]', '<a class="nonexistent" href="/something">some text</a>'),
502
 
        ('[[../something]]', '<a class="nonexistent" href="/something">../something</a>'),
503
 
        ('[[/something]]', '<a class="nonexistent" href="/%s/something">/something</a>' % PAGENAME),
504
 
        ('[[something#anchor]]', '<a class="nonexistent" href="/something#anchor">something#anchor</a>'),
 
521
        ('SomeNonExistentPage', '<a class="nonexistent" href="./SomeNonExistentPage">SomeNonExistentPage</a>'),
 
522
        ('SomeNonExistentPage#anchor', '<a class="nonexistent" href="./SomeNonExistentPage#anchor">SomeNonExistentPage#anchor</a>'),
 
523
        ('[[something]]', '<a class="nonexistent" href="./something">something</a>'),
 
524
        ('[[some thing]]', '<a class="nonexistent" href="./some%20thing">some thing</a>'),
 
525
        ('[[something|some text]]', '<a class="nonexistent" href="./something">some text</a>'),
 
526
        ('[[../something]]', '<a class="nonexistent" href="./something">../something</a>'),
 
527
        ('[[/something]]', '<a class="nonexistent" href="./%s/something">/something</a>' % PAGENAME),
 
528
        ('[[something#anchor]]', '<a class="nonexistent" href="./something#anchor">something#anchor</a>'),
505
529
        ('MoinMoin:something', '<a class="interwiki" href="http://moinmo.in/something" title="MoinMoin">something</a>'),
506
530
        ('[[MoinMoin:something|some text]]', '<a class="interwiki" href="http://moinmo.in/something" title="MoinMoin">some text</a>'),
507
531
        ('[[MoinMoin:with space]]', '<a class="interwiki" href="http://moinmo.in/with%20space" title="MoinMoin">with space</a>'),
508
532
        ('[[MoinMoin:with space|some text]]', '<a class="interwiki" href="http://moinmo.in/with%20space" title="MoinMoin">some text</a>'),
509
533
        # no interwiki:
510
 
        ('[[ABC:n]]', '<a class="nonexistent" href="/ABC%3An">ABC:n</a>'), # finnish/swedish abbreviations / possessive
 
534
        ('[[ABC:n]]', '<a class="nonexistent" href="./ABC%3An">ABC:n</a>'), # finnish/swedish abbreviations / possessive
511
535
        ('ABC:n', 'ABC:n'), # finnish/swedish abbreviations / possessive
512
536
        ('lowercase:nointerwiki', 'lowercase:nointerwiki'),
513
537
        ('[[http://google.com/|google]]', '<a class="http" href="http://google.com/">google</a>'),