Back to index

moin  1.9.0~rc2
test_text_html_text_moin_wiki.py
Go to the documentation of this file.
00001 # -*- coding: utf-8 -*-
00002 """
00003     MoinMoin - MoinMoin.text_html_text_moin_wiki Tests
00004 
00005     @copyright: 2005 by Bastian Blank,
00006                 2005,2007 by MoinMoin:ThomasWaldmann
00007     @license: GNU GPL, see COPYING for details.
00008 """
00009 
00010 import py
00011 #py.test.skip("Many broken tests, much broken code, broken, broken, broken.")
00012 
00013 from cStringIO import StringIO
00014 from MoinMoin.converter import text_html_text_moin_wiki as converter
00015 from MoinMoin.parser.text_moin_wiki import Parser
00016 from MoinMoin.formatter.text_gedit import Formatter
00017 from MoinMoin.util.clock import Clock
00018 from MoinMoin.error import ConvertError
00019 
00020 convert = converter.convert
00021 error = ConvertError
00022 
00023 
00024 class TestBase(object):
00025 
00026     def do_convert_real(self, func_args, successful=True):
00027         try:
00028             ret = convert(*func_args)
00029         except error, e:
00030             if successful:
00031                 py.test.fail("fails with parse error: %s" % e)
00032             else:
00033                 return
00034         if successful:
00035             return ret
00036         else:
00037             py.test.fail("doesn't fail with parse error")
00038 
00039 
00040 class MinimalPage(object):
00041     def __init__(self):
00042         self.hilite_re = None
00043         self.page_name = "testpage"
00044 
00045 
00046 class MinimalRequest(object):
00047     # TODO: do we really need this class? no other test uses a request replacement.
00048 
00049     def __init__(self, request):
00050         self.request = request
00051         self.clock = Clock()
00052 
00053         # This is broken - tests that need correct content_lang will fail
00054         self.content_lang = None
00055         self.current_lang = None
00056 
00057         self.form = {}
00058         self._page_headings = {}
00059         self.result = []
00060 
00061     def getText(self, text, wiki=False, percent=False):
00062         return text
00063 
00064     def write(self, text):
00065         self.result.append(text)
00066 
00067     def __getattr__(self, name):
00068         return getattr(self.request, name)
00069 
00070 
00071 class TestConvertBlockRepeatable(TestBase):
00072     def do(self, text, output):
00073         text = text.lstrip('\n')
00074         output = output.strip('\n')
00075         request = MinimalRequest(self.request)
00076         page = MinimalPage()
00077         formatter = Formatter(request)
00078         formatter.setPage(page)
00079         Parser(text, request).format(formatter)
00080         repeat = ''.join(request.result).strip('\n')
00081         #assert repeat == output
00082         out = self.do_convert_real([request, page.page_name, repeat])
00083         assert text == out
00084 
00085     def testComment01(self):
00086         test = ur"""
00087 ##test
00088 """
00089         output = u"""<pre class="comment">\n##test</pre>"""
00090         self.do(test, output)
00091 
00092     def testComment02(self):
00093         test = ur"""
00094 ##test
00095 ##test
00096 """
00097         output = u"""
00098 <pre class="comment">\n##test</pre>
00099 <pre class="comment">\n##test</pre>
00100 """
00101         self.do(test, output)
00102 
00103     def testHeading01(self):
00104         py.test.skip('broken test')
00105         test = ur"""
00106 = test1 =
00107 
00108 """
00109         output = ur"""
00110 <h2>test1</h2>
00111 """
00112         self.do(test, output)
00113 
00114     def testHeading02(self):
00115         py.test.skip('broken test')
00116         test = ur"""
00117 = test1 =
00118 
00119 == test2 ==
00120 
00121 """
00122         output = ur"""
00123 <h2>test1</h2>
00124 <h3>test2</h3>
00125 """
00126         self.do(test, output)
00127 
00128     def testListSuccess01(self):
00129         test = ur"""
00130  * test
00131 
00132 """
00133         output = ur"""
00134 <ul>
00135 <li><p>test </p>
00136 </li>
00137 </ul>
00138 """
00139         self.do(test, output)
00140 
00141     def testListSuccess02(self):
00142         test = ur"""
00143  1. test
00144 
00145 """
00146         output = ur"""
00147 <ol type="1">
00148 <li><p>test </p>
00149 </li>
00150 </ol>
00151 """
00152         self.do(test, output)
00153 
00154     def testListSuccess03(self):
00155         test = ur"""
00156  test:: test
00157 
00158 """
00159         output = ur"""
00160 <dl>
00161 <dt>test</dt>
00162 <dd><p>test </p>
00163 </dd>
00164 </dl>
00165 """
00166         self.do(test, output)
00167 
00168     def testListSuccess04(self):
00169         test = ur"""
00170  * test
00171  * test
00172 
00173 """
00174         output = ur"""
00175 <ul>
00176 <li><p>test </p>
00177 </li>
00178 <li><p>test </p>
00179 </li>
00180 </ul>
00181 """
00182         self.do(test, output)
00183 
00184     def testListSuccess05(self):
00185         test = ur"""
00186  1. test
00187  1. test
00188 
00189 """
00190         output = ur"""
00191 <ol type="1">
00192 <li><p>test </p>
00193 </li>
00194 <li><p>test </p>
00195 </li>
00196 </ol>
00197 """
00198         self.do(test, output)
00199 
00200     def testListSuccess06(self):
00201         test = ur"""
00202  test:: test
00203  test:: test
00204 
00205 """
00206         output = ur"""
00207 <dl>
00208 <dt>test</dt>
00209 <dd><p>test </p>
00210 </dd>
00211 <dt>test</dt>
00212 <dd><p>test </p>
00213 </dd>
00214 </dl>
00215 """
00216         self.do(test, output)
00217 
00218     def testListSuccess07(self):
00219         test = ur"""
00220  * test
00221 
00222  * test
00223 
00224 """
00225         output = ur"""
00226 <ul>
00227 <li><p>test </p>
00228 </li>
00229 </ul>
00230 <ul>
00231 <li><p>test </p>
00232 </li>
00233 </ul>
00234 """
00235         self.do(test, output)
00236 
00237     def testListSuccess08(self):
00238         test = ur"""
00239  1. test
00240 
00241  1. test
00242 
00243 """
00244         output = ur"""
00245 <ol type="1">
00246 <li><p>test </p>
00247 </li>
00248 </ol>
00249 <ol type="1">
00250 <li><p>test </p>
00251 </li>
00252 </ol>
00253 """
00254         self.do(test, output)
00255 
00256     def testListSuccess09(self):
00257         py.test.skip('broken test')
00258         test = ur"""
00259  test:: test
00260 
00261  test:: test
00262 
00263 """
00264         output = ur"""
00265 <dl>
00266 <dt>test</dt>
00267 <dd><p>test </p>
00268 </dd>
00269 </dl>
00270 <dl>
00271 <dt>test</dt>
00272 <dd><p>test </p>
00273 </dd>
00274 </dl>
00275 """
00276         self.do(test, output)
00277 
00278     def testListSuccess10(self):
00279         py.test.skip('broken test')
00280         test = ur"""
00281  * test
00282   * test
00283 
00284 """
00285         output = ur"""
00286 <ul>
00287 <li><p>test </p>
00288 <ul>
00289 <li><p>test </p>
00290 </li>
00291 </ul>
00292 </li>
00293 </ul>
00294 """
00295         self.do(test, output)
00296 
00297     def testListSuccess11(self):
00298         py.test.skip('broken test')
00299         test = ur"""
00300  1. test
00301   1. test
00302 
00303 """
00304         output = ur"""
00305 <ol type="1">
00306 <li><p>test </p>
00307 <ol type="1">
00308 <li><p>test </p>
00309 </li>
00310 </ol>
00311 </li>
00312 </ol>
00313 """
00314         self.do(test, output)
00315 
00316     def testListSuccess12(self):
00317         py.test.skip('broken test')
00318         test = ur"""
00319  test:: test
00320   test:: test
00321 
00322 """
00323         output = ur"""
00324 <dl>
00325 <dt>test</dt>
00326 <dd><p>test </p>
00327 <dl>
00328 <dt>test</dt>
00329 <dd><p>test </p>
00330 </dd>
00331 </dl>
00332 </dd>
00333 </dl>
00334 """
00335         self.do(test, output)
00336 
00337     def testListSuccess13(self):
00338         test = ur"""
00339  * test
00340   * test
00341  * test
00342 
00343 """
00344         output = ur"""
00345 <ul>
00346 <li><p>test </p>
00347 <ul>
00348 <li><p>test </p>
00349 </li>
00350 </ul>
00351 </li>
00352 <li><p>test </p>
00353 </li>
00354 </ul>
00355 """
00356         self.do(test, output)
00357 
00358     def testListSuccess14(self):
00359         test = ur"""
00360  1. test
00361   1. test
00362  1. test
00363 
00364 """
00365         output = ur"""
00366 <ol type="1">
00367 <li><p>test </p>
00368 <ol type="1">
00369 <li><p>test </p>
00370 </li>
00371 </ol>
00372 </li>
00373 <li><p>test </p>
00374 </li>
00375 </ol>
00376 """
00377         self.do(test, output)
00378 
00379     def testListSuccess15(self):
00380         test = ur"""
00381  test:: test
00382   test:: test
00383  test:: test
00384 
00385 """
00386         output = ur"""
00387 <dl>
00388 <dt>test</dt>
00389 <dd><p>test </p>
00390 <dl>
00391 <dt>test</dt>
00392 <dd><p>test </p>
00393 </dd>
00394 </dl>
00395 </dd>
00396 <dt>test</dt>
00397 <dd><p>test </p>
00398 </dd>
00399 </dl>
00400 """
00401         self.do(test, output)
00402 
00403     def testListSuccess16(self):
00404         py.test.skip('broken test')
00405         test = ur"""
00406  * test
00407 
00408  1. test
00409 
00410 """
00411         output = ur"""
00412 <ul>
00413 <li><p>test </p>
00414 </li>
00415 </ul>
00416 <ol type="1">
00417 <li><p>test </p>
00418 </li>
00419 </ol>
00420 """
00421         self.do(test, output)
00422 
00423     def testListSuccess17(self):
00424         py.test.skip('broken test')
00425         test = ur"""
00426  * test
00427 
00428  test:: test
00429 
00430 """
00431         output = ur"""
00432 <ul>
00433 <li><p>test </p>
00434 </li>
00435 </ul>
00436 <dl>
00437 <dt>test</dt>
00438 <dd><p>test </p>
00439 </dd>
00440 </dl>
00441 """
00442         self.do(test, output)
00443 
00444     def testListSuccess18(self):
00445         py.test.skip('broken test')
00446         test = ur"""
00447  1. test
00448 
00449  * test
00450 
00451 """
00452         output = ur"""
00453 <ol type="1">
00454 <li><p>test </p>
00455 </li>
00456 </ol>
00457 <ul>
00458 <li><p>test </p>
00459 </li>
00460 </ul>
00461 """
00462         self.do(test, output)
00463 
00464     def testListSuccess19(self):
00465         py.test.skip('broken test')
00466         test = ur"""
00467  1. test
00468 
00469  test:: test
00470 
00471 """
00472         output = ur"""
00473 <ol type="1">
00474 <li><p>test </p>
00475 </li>
00476 </ol>
00477 <dl>
00478 <dt>test</dt>
00479 <dd><p>test </p>
00480 </dd>
00481 </dl>
00482 """
00483         self.do(test, output)
00484 
00485     def testListSuccess20(self):
00486         py.test.skip('broken test')
00487         test = ur"""
00488  test:: test
00489 
00490  * test
00491 
00492 """
00493         output = ur"""
00494 <dl>
00495 <dt>test</dt>
00496 <dd><p>test </p>
00497 </dd>
00498 </dl>
00499 <ul>
00500 <li><p>test </p>
00501 </li>
00502 </ul>
00503 """
00504         self.do(test, output)
00505 
00506     def testListSuccess21(self):
00507         py.test.skip('broken test')
00508         test = ur"""
00509  test:: test
00510 
00511  1. test
00512 
00513 """
00514         output = ur"""
00515 <dl>
00516 <dt>test</dt>
00517 <dd><p>test </p>
00518 </dd>
00519 </dl>
00520 <ol type="1">
00521 <li><p>test </p>
00522 </li>
00523 </ol>
00524 """
00525         self.do(test, output)
00526 
00527     def testListSuccess23(self):
00528         py.test.skip('broken test')
00529         test = ur"""
00530  1. test
00531   * test
00532 
00533 """
00534         output = ur"""
00535 <ol type="1">
00536 <li><p>test </p>
00537 <ul>
00538 <li><p>test </p>
00539 </li>
00540 </ul>
00541 </li>
00542 </ol>
00543 """
00544         self.do(test, output)
00545 
00546     def testListSuccess26(self):
00547         py.test.skip('broken test')
00548         test = ur"""
00549  * test
00550 
00551 test
00552 
00553 """
00554         output = ur"""
00555 <ul>
00556 <li><p>test </p>
00557 </li>
00558 </ul>
00559 <p>test </p>
00560 """
00561         self.do(test, output)
00562 
00563     def testListSuccess28(self):
00564         py.test.skip('broken test')
00565         test = ur"""
00566  * test
00567 
00568  test
00569 
00570 """
00571         output = ur"""
00572 <ul>
00573 <li><p>test </p>
00574 <p>test </p>
00575 </li>
00576 </ul>
00577 """
00578         self.do(test, output)
00579 
00580     def testListSuccess29(self):
00581         py.test.skip('broken test')
00582         test = ur"""
00583  * test
00584   * test
00585  test
00586 """
00587         output = ur"""
00588 """
00589         self.do(test, output)
00590 
00591     def testListSuccess30(self):
00592         py.test.skip('broken test')
00593         test = ur"""
00594  * test
00595   * test
00596   test
00597 """
00598         output = ur"""
00599 """
00600         self.do(test, output)
00601 
00602     def testParagraph1(self):
00603         py.test.skip('broken test')
00604         test = ur"""
00605 test
00606 
00607 """
00608         output = ur"""
00609 <p>test </p>
00610 """
00611         self.do(test, output)
00612 
00613     def testParagraph2(self):
00614         py.test.skip('broken test')
00615         test = ur"""
00616 test
00617 
00618 test
00619 
00620 """
00621         output = ur"""
00622 <p>test </p>
00623 <p>test </p>
00624 """
00625         self.do(test, output)
00626 
00627     def testPreSuccess1(self):
00628         py.test.skip('broken test')
00629         test = ur"""
00630 {{{
00631 test
00632 }}}
00633 
00634 """
00635         output = ur"""
00636 <pre>
00637 test
00638 </pre>
00639 """
00640         self.do(test, output)
00641 
00642     def testPreSuccess2(self):
00643         py.test.skip('broken test')
00644         test = ur"""
00645 {{{
00646 test
00647 test
00648 }}}
00649 
00650 """
00651         output = ur"""
00652 <pre>
00653 test
00654 test
00655 </pre>
00656 """
00657         self.do(test, output)
00658 
00659     def testPreSuccess3(self):
00660         py.test.skip('broken test')
00661         test = ur"""
00662 {{{
00663 test
00664 
00665 test
00666 }}}
00667 
00668 """
00669         output = ur"""
00670 <pre>
00671 test
00672 
00673 test
00674 </pre>
00675 """
00676         self.do(test, output)
00677 
00678     def testPreSuccess4(self):
00679         py.test.skip('broken test')
00680         test = ur"""
00681 {{{
00682  * test
00683 }}}
00684 
00685 """
00686         output = ur"""
00687 <pre>
00688  * test
00689 </pre>
00690 """
00691         self.do(test, output)
00692 
00693     def testPreSuccess5(self):
00694         py.test.skip('broken test')
00695         test = ur"""
00696 {{{
00697   }}}
00698 
00699 """
00700         output = ur"""
00701 <pre>
00702   </pre>
00703 """
00704         self.do(test, output)
00705 
00706     def testPreSuccess6(self):
00707         test = ur"""
00708  * {{{
00709 test
00710 }}}
00711 
00712 """
00713         output = ur"""
00714 <ul>
00715 <li>
00716 <pre>
00717 test
00718 </pre>
00719 </li>
00720 </ul>
00721 """
00722         self.do(test, output)
00723 
00724     def testPreSuccess7(self):
00725         py.test.skip("Broken.")
00726         test = ur"""
00727  * {{{
00728    test
00729    }}}
00730 
00731 """
00732         output = ur"""
00733 <ul>
00734 <li>
00735 <pre>
00736    test
00737    </pre>
00738 </li>
00739 </ul>
00740 """
00741         self.do(test, output)
00742 
00743     def testPreSuccess8(self):
00744         test = ur"""
00745  * test
00746  {{{
00747 test
00748 }}}
00749 
00750 """
00751         output = ur"""
00752 <ul>
00753 <li><p>test
00754 </p>
00755 <pre>
00756 test
00757 </pre>
00758 </li>
00759 </ul>
00760 """
00761         self.do(test, output)
00762 
00763     def testPreSuccess9(self):
00764         py.test.skip('broken test')
00765         test = ur"""
00766  * test
00767 
00768 {{{
00769 test
00770 }}}
00771 
00772 """
00773         output = ur"""
00774 <ul>
00775 <li><p>test </p>
00776 </li>
00777 </ul>
00778 
00779 <pre>
00780 test
00781 </pre>
00782 """
00783         self.do(test, output)
00784 
00785     def testPreSuccess10(self):
00786         test = ur"""
00787  * {{{{
00788 {{{
00789 test
00790 }}}
00791 }}}}
00792 
00793 """
00794         output = ur"""
00795 <ul>
00796 <li>
00797 <pre>
00798 {{{
00799 test
00800 }}}
00801 </pre>
00802 </li>
00803 </ul>
00804 """
00805 
00806     def testPreSuccess11(self):
00807         test = ur"""
00808  * {{{{
00809 test
00810 }}}
00811 }}}}
00812 
00813 """
00814         output = ur"""
00815 <ul>
00816 <li>
00817 <pre>
00818 test
00819 }}}
00820 </pre>
00821 </li>
00822 </ul>
00823 """
00824 
00825     def testPreSuccess12(self):
00826         test = ur"""
00827  * {{{{
00828 {{{
00829 test
00830 }}}}
00831 
00832 """
00833         output = ur"""
00834 <ul>
00835 <li>
00836 <pre>
00837 {{{
00838 test
00839 </pre>
00840 </li>
00841 </ul>
00842 """
00843 
00844         self.do(test, output)
00845 
00846     def testRule1(self):
00847         py.test.skip('broken test')
00848         test = ur"""
00849 ----
00850 
00851 """
00852         output = ur"""
00853 <hr/>
00854 """
00855         self.do(test, output)
00856 
00857     def testTable01(self):
00858         py.test.skip('broken test')
00859         test = ur"""
00860 || ||
00861 
00862 """
00863         output = ur"""
00864 <div>
00865 <table>
00866 <tr>
00867 <td>
00868 <p> </p>
00869 </td>
00870 </tr>
00871 </table>
00872 </div>
00873 """
00874         self.do(test, output)
00875 
00876     def testTable02(self):
00877         py.test.skip('broken test')
00878         test = ur"""
00879 ||test||
00880 
00881 """
00882         output = ur"""
00883 <div>
00884 <table>
00885 <tr>
00886 <td>
00887 <p>test</p>
00888 </td>
00889 </tr>
00890 </table>
00891 </div>
00892 """
00893         self.do(test, output)
00894 
00895     def testTable03(self):
00896         py.test.skip('broken test')
00897         test = ur"""
00898 ||test||test||
00899 
00900 """
00901         output = ur"""
00902 <table>
00903 <tr>
00904 <td>
00905 <p class="line862">
00906 test
00907 </td>
00908 <td>
00909 <p class="line862">test
00910 </td>
00911 </tr>
00912 </table>
00913 """
00914         self.do(test, output)
00915 
00916     def testTable04(self):
00917         py.test.skip('broken test')
00918         test = ur"""
00919 ||test||
00920 ||test||test||
00921 
00922 """
00923         output = ur"""
00924 <div>
00925 <table>
00926 <tr>
00927 <td>
00928 <p>test</p>
00929 </td>
00930 </tr>
00931 <tr>
00932 <td>
00933 <p>test</p>
00934 </td>
00935 <td>
00936 <p>test</p>
00937 </td>
00938 </tr>
00939 </table>
00940 </div>
00941 """
00942         self.do(test, output)
00943 
00944     def testTable05(self):
00945         py.test.skip('broken test')
00946         test = ur"""
00947 ||||test||
00948 ||test||test||
00949 
00950 """
00951         output = ur"""
00952 <div>
00953 <table>
00954 <tr>
00955 <td colspan="2" style="text-align: center;">
00956 <p>test</p>
00957 </td>
00958 </tr>
00959 <tr>
00960 <td>
00961 <p>test</p>
00962 </td>
00963 <td>
00964 <p>test</p>
00965 </td>
00966 </tr>
00967 </table>
00968 </div>
00969 """
00970         self.do(test, output)
00971 
00972     def testTable06(self):
00973         py.test.skip('broken test')
00974         test = ur"""
00975 ||||test||test||
00976 ||test||||test||
00977 
00978 """
00979         output = ur"""
00980 <table><tbody><tr>  <td style="text-align: center;"
00981 colspan="2"><p class="line862">test</p></td>   <td><p class="line862">test</p></td>
00982 </tr> <tr>  <td><p class="line862">test</p></td>   <td style="text-align: center;"
00983 colspan="2"><p class="line862">test</p></td> </tr> </tbody></table>"""
00984         self.do(test, output)
00985 
00986 class TestConvertInlineFormatRepeatable(TestBase):
00987     def do(self, text, output):
00988         text = text.lstrip('\n')
00989         output = output.strip('\n')
00990         output = "<p>%s </p>" % output
00991         request = MinimalRequest(self.request)
00992         page = MinimalPage()
00993         formatter = Formatter(request)
00994         formatter.setPage(page)
00995         Parser(text, request).format(formatter)
00996         repeat = ''.join(request.result).strip('\n')
00997         #assert repeat == output
00998         out = self.do_convert_real([request, page.page_name, repeat])
00999         out = out.rstrip('\n')
01000         assert text == out
01001 
01002     def testEmphasis01(self):
01003         py.test.skip('broken test')
01004         test = ur"''test''"
01005         output = ur"<em>test</em>"
01006         self.do(test, output)
01007 
01008     def testEmphasis02(self):
01009         py.test.skip('broken test')
01010         test = ur"'''test'''"
01011         output = ur"<strong>test</strong>"
01012         self.do(test, output)
01013 
01014     def testEmphasis03(self):
01015         py.test.skip('broken test')
01016         test = ur"'''''test'''''"
01017         output = ur"<em><strong>test</strong></em>"
01018         self.do(test, output)
01019 
01020     def testEmphasis04(self):
01021         py.test.skip('broken test')
01022         test = ur"''test'''test'''''"
01023         output = ur"<em>test<strong>test</strong></em>"
01024         self.do(test, output)
01025 
01026     def testEmphasis05(self):
01027         py.test.skip('broken test')
01028         test = ur"'''test''test'''''"
01029         output = ur"<strong>test<em>test</em></strong>"
01030         self.do(test, output)
01031 
01032     def testEmphasis06(self):
01033         py.test.skip('broken test')
01034         test = ur"''test'''test'''test''"
01035         output = ur"<em>test<strong>test</strong>test</em>"
01036         self.do(test, output)
01037 
01038     def testEmphasis07(self):
01039         py.test.skip('broken test')
01040         test = ur"'''test''test''test'''"
01041         output = ur"<strong>test<em>test</em>test</strong>"
01042         self.do(test, output)
01043 
01044     def testEmphasis08(self):
01045         py.test.skip('broken test')
01046         test = ur"''test'''''test'''"
01047         output = ur"<em>test</em><strong>test</strong>"
01048         self.do(test, output)
01049 
01050     def testEmphasis09(self):
01051         py.test.skip('broken test')
01052         test = ur"'''test'''''test''"
01053         output = ur"<strong>test</strong><em>test</em>"
01054         self.do(test, output)
01055 
01056     def testEmphasis10(self):
01057         py.test.skip('broken test')
01058         test = ur"'''''test''test'''"
01059         output = ur"<strong><em>test</em>test</strong>"
01060         self.do(test, output)
01061 
01062     def testEmphasis11(self):
01063         py.test.skip('broken test')
01064         test = ur"'''''test'''test''"
01065         output = ur"<em><strong>test</strong>test</em>"
01066         self.do(test, output)
01067 
01068     def testFormatBig01(self):
01069         py.test.skip('broken test')
01070         test = ur"~+test+~"
01071         output = ur"<big>test</big>"
01072         self.do(test, output)
01073 
01074     def testFormatSmall01(self):
01075         py.test.skip('broken test')
01076         test = ur"~-test-~"
01077         output = ur"<small>test</small>"
01078         self.do(test, output)
01079 
01080     def testFormatStrike01(self):
01081         py.test.skip('broken test')
01082         test = ur"--(test)--"
01083         output = ur"<strike>test</strike>"
01084         self.do(test, output)
01085 
01086     def testFormatSub01(self):
01087         py.test.skip('broken test')
01088         test = ur",,test,,"
01089         output = ur"<sub>test</sub>"
01090         self.do(test, output)
01091 
01092     def testFormatSup01(self):
01093         py.test.skip('broken test')
01094         test = ur"^test^"
01095         output = ur"<sup>test</sup>"
01096         self.do(test, output)
01097 
01098     def testFormatUnderline01(self):
01099         py.test.skip('broken test')
01100         test = ur"__test__"
01101         output = ur"<u>test</u>"
01102         self.do(test, output)
01103 
01104     def testPre01(self):
01105         py.test.skip('broken test')
01106         test = ur"{{{test}}}"
01107         output = ur"<tt>test</tt>"
01108         self.do(test, output)
01109 
01110     def testWhitespace01(self):
01111         py.test.skip('broken test')
01112         test = ur"''test '''test'''''"
01113         output = ur"<em>test <strong>test</strong></em>"
01114         self.do(test, output)
01115 
01116 class TestConvertInlineItemRepeatable(TestBase):
01117     def do(self, text, output):
01118         text = text.lstrip('\n')
01119         output = output.strip('\n')
01120         output = "<p>%s </p>" % output
01121         request = MinimalRequest(self.request)
01122         page = MinimalPage()
01123         formatter = Formatter(request)
01124         formatter.setPage(page)
01125         Parser(text, request).format(formatter)
01126         repeat = ''.join(request.result).strip('\n')
01127         #assert repeat == output
01128         out = self.do_convert_real([request, page.page_name, repeat])
01129         out = out.rstrip('\n')
01130         assert text == out
01131 
01132     def testWikiWord01(self):
01133         py.test.skip('broken test')
01134         test = ur"WikiWord"
01135         output = ur"""<a class="nonexistent" href="./WikiWord">WikiWord</a>"""
01136         self.do(test, output)
01137 
01138     def testNoWikiWord01(self):
01139         py.test.skip('broken test')
01140         test = ur"!WikiWord"
01141         output = ur"WikiWord"
01142         self.do(test, output)
01143 
01144     def testSmiley01(self):
01145         py.test.skip('broken test')
01146         test = ur":-)"
01147         output = ur"""<img src="/wiki/modern/img/smile.png" alt=":-)" height="15" width="15">"""
01148         self.do(test, output)
01149 
01150 class TestStrip(object):
01151     def do(self, cls, text, output):
01152         tree = converter.parse(self.request, text)
01153         cls().do(tree)
01154         out = StringIO()
01155         try:
01156             import xml.dom.ext
01157         except ImportError:
01158             py.test.skip('xml.dom.ext module is not available')
01159         xml.dom.ext.Print(tree, out)
01160         assert "<?xml version='1.0' encoding='UTF-8'?>%s" % output == out.getvalue().decode("utf-8")
01161 
01162 class TestStripWhitespace(TestStrip):
01163     def do(self, text, output):
01164         super(TestStripWhitespace, self).do(converter.strip_whitespace, text, output)
01165 
01166     def test1(self):
01167         test = ur"""
01168 <t/>
01169 """
01170         output = ur"""<t/>"""
01171         self.do(test, output)
01172 
01173     def test2(self):
01174         py.test.skip('broken test')
01175         test = ur"""
01176 <t>
01177   <z/>
01178 </t>
01179 """
01180         output = ur"""<t><z/></t>"""
01181         self.do(test, output)
01182 
01183     def test3(self):
01184         py.test.skip('broken test')
01185         test = ur"""
01186 <t>
01187   <z>test</z>
01188 </t>
01189 """
01190         output = ur"""<t><z>test</z></t>"""
01191         self.do(test, output)
01192 
01193     def test4(self):
01194         test = ur"""<p>&nbsp;</p>"""
01195         output = ur""""""
01196         self.do(test, output)
01197 
01198     def test5(self):
01199         test = ur"""<p>test </p>"""
01200         output = ur"""<p>test</p>"""
01201         self.do(test, output)
01202 
01203 class TestConvertBrokenBrowser(TestBase):
01204     def do(self, text, output):
01205         text = text.strip('\n')
01206         output = output.strip()
01207         request = MinimalRequest(self.request)
01208         page = MinimalPage()
01209         out = self.do_convert_real([request, page.page_name, text])
01210         out = out.strip()
01211 
01212         assert output == out
01213 
01214     def testList01(self):
01215         test = ur"""
01216 <ul>
01217 <li>test</li>
01218 <ul>
01219 <li>test</li>
01220 </ul>
01221 <li>test</li>
01222 </ul>
01223 """
01224         output = ur"""
01225  * test
01226   * test
01227  * test
01228 
01229 """
01230         self.do(test, output)
01231 
01232 class TestBlanksInTables(TestBase):
01233     def do(self, text, output):
01234         text = text.strip('\n')
01235         output = output.strip('\n')
01236         request = MinimalRequest(self.request)
01237         page = MinimalPage()
01238         out = self.do_convert_real([request, page.page_name, text])
01239         out = out.strip()
01240         assert output == out
01241 
01242     def testTable01(self):
01243         # tests empty cells
01244         test = u"<table><tbody><tr><td>a</td><td></td></tr></tbody></table>"
01245         output = u"||a|| ||"
01246 
01247         self.do(test, output)
01248 
01249     def testTable02(self):
01250         # tests empty cells by br (OOo cut and paste)
01251         test = u"<table><tbody><tr><td>a</td><td><br /></td></tr></tbody></table>"
01252         output = u"||a||<<BR>>||"
01253 
01254         self.do(test, output)
01255 
01256     def testTable03(self):
01257         # tests linebreak in cells by br
01258         test = u"<table><tbody><tr><td>a<br />b</td></tr></tbody></table>"
01259         output = u"||a<<BR>>b||"
01260 
01261         self.do(test, output)
01262 
01263     def testTable04(self):
01264         # tests linebreak in cells by br and formatting styles
01265         test = u"<table><tbody><tr><td><em>a</em><br /><u>b</u><br /><strike>c</strike></td></tr></tbody></table>"
01266         output = u"||''a''<<BR>>__b__<<BR>>--(c)--||"
01267 
01268         self.do(test, output)
01269 
01270     def testTable05(self):
01271         # tests empty cells and formatting style strong
01272         test = u"""
01273 <table><tbody>
01274 <tr><td><strong>a</strong></td><td></td></tr>
01275 <tr><td></td><td><strong>b</strong></td></tr>
01276 </tbody></table>
01277 """
01278         output = u"""
01279 ||'''a'''|| ||
01280 || ||'''b'''||
01281 """
01282         self.do(test, output)
01283 
01284     def testTable06(self):
01285         # tests linebreak in cells by br
01286         test = u"<table><tbody><tr><td>a<br /></td></tr></tbody></table>"
01287         output = u"||a<<BR>>||"
01288 
01289         self.do(test, output)
01290 
01291     def testTable07(self):
01292         # tests empty cells from OOo and formatting style strong
01293         test = u"""
01294 <table><tbody>
01295 <tr><td><strong>a</strong></td><td><strong><br /></strong></td></tr>
01296 <tr><td><strong><br /></strong></td><td><strong>b</strong></td></tr>
01297 </tbody></table>
01298 """
01299 
01300         output = u"""
01301 ||'''a'''||''''''||
01302 ||''''''||'''b'''||
01303 """
01304 
01305         self.do(test, output)
01306 
01307     def testTable08(self):
01308         # tests line break between two lines in formatted text
01309         test = u"<table><tbody><tr><td><strong>first line<br />second line</strong></td></tr></tbody></table>"
01310         output = u"||'''first line<<BR>>second line'''||"
01311 
01312         self.do(test, output)
01313 
01314     def testTable09(self):
01315         # tests line break at beginning of line and formatted text
01316         test = u"<table><tbody><tr><td><strong><br />line</strong></td></tr></tbody></table>"
01317         output = u"||'''<<BR>>line'''||"
01318 
01319     def testTable10(self):
01320         # tests line break at end of line and formatted text
01321         test = u"<table><tbody><tr><td><strong>line<br /></strong></td></tr></tbody></table>"
01322         output = u"||'''line<<BR>>'''||"
01323 
01324     def testTable11(self):
01325         # tests line break at beginning before formatted text
01326         test = u"<table><tbody><tr><td><br /><strong>line</strong></td></tr></tbody></table>"
01327         output = u"||'<<BR>'''line'''||"
01328 
01329     def testTable12(self):
01330         # tests line break after formatted text
01331         test = u"<table><tbody><tr><td><strong>line</strong><br /></td></tr></tbody></table>"
01332         output = u"||'''line'''<<BR>>||"
01333 
01334     def testTable13(self):
01335         # tests formatted br
01336         test = u"<table><tbody><tr><td><strong><br /></strong></td></tr></tbody></table>"
01337         output = u"||''''''||"
01338 
01339     def testTable14(self):
01340         # tests br
01341         test = u"<table><tbody><tr><td><br /></td></tr></tbody></table>"
01342         output = u"||<<BR>>||"
01343 
01344     def testTable15(self):
01345         # tests many br
01346         test = u"<table><tbody><tr><td><br /><br /><br /></td></tr></tbody></table>"
01347         output = u"||<<BR>><<BR>><<BR>>||"
01348 
01349         self.do(test, output)
01350 
01351 coverage_modules = ['MoinMoin.converter.text_html_text_moin_wiki']
01352