def test_3_redirect( self ) : """Testing the Redirect() macro""" print "\nTesting the Redirect() macro" log.info( "Testing the Redirect() macro" ) testlist = [ '\n'.join([ gen_texts( words, [] , [], [], tc=5, pc=0, ec=0, lc=0, mc=0, hc=0, fc=0, nopipe=True ) for j in range(randint(0,10)) ]) for k in range(100) ] redirect_macros = [ [ '{{ Redirect("Hello World") }}', [ 'Hello World' ] ], [ '{{ Redirect("/") }}', [ '/' ] ], [ '{{ Redirect("/hello/world") }}', [ '/hello/world' ] ], ] def redirect_cfunc( macro_ref ) : def cfunc( ref, tu ) : tu.tohtml() [ assert_true( r == tu.parser.etparser.redirect, 'Fail Redirect Macro' ) for r in macro_ref ] return cfunc testcount = 1 for t in testlist : m = choice( redirect_macros ) t = m[0] + t yield self._test_execute, 'macro_redirect', t, testcount, '', \ redirect_cfunc( m[1] ) testcount += 1
def test_4_html( self ) : """Testing the Html() macro""" print "\nTesting the Html() macro" log.info( "Testing the Html() macro" ) testlist = [ '\n'.join([ gen_texts( words, [], [], [], tc=5, pc=0, ec=0, lc=0, mc=0, hc=0, fc=0, nopipe=True ) for j in range(randint(0,10)) ]) for k in range(100) ] html_macros = [ [ '{{ Html("<table><tr><td>hello world</td></tr></table>") }}', [ '<table><tr><td>hello world</td></tr></table>' ] ], ] def html_cfunc( macro_ref ) : def cfunc( ref, tu ) : html= tu.tohtml() [ assert_true( r in html, 'Fail Html Macro : %s ' % html ) for r in macro_ref ] return cfunc testcount = 1 for t in testlist : off = randint( 0, len(t) ) m = choice( html_macros ) t = t[:off] + m[0] + t[off:] yield self._test_execute, 'macro_html', t, testcount, '', \ html_cfunc( m[1] ) testcount += 1
def test_1_clear( self ) : """Testing the Clear() macro""" print "\nTesting the Clear() macro" log.info( "Testing the Clear() macro" ) testlist = [ '\n'.join([ gen_texts( words, [] , [], [], tc=5, pc=0, ec=0, lc=0, mc=0, hc=0, fc=0, nopipe=True ) for j in range(randint(0,10)) ]) for k in range(100) ] clear_macros = [ '{{ Clear() }}', '{{Clear() }}', '{{ Clear() }}' ] def clear_cfunc( ref, tu ): html= tu.tohtml() assert_true( 'class="etm-clear"' in html, 'Fail Clear Macro : %s ' % html ) testcount = 1 for t in testlist : off = randint( 0, len(t) ) t = t.replace( '{', '' ) t = t.replace( '}', '' ) t = t[:off] + choice( clear_macros ) + t[off:] yield self._test_execute, 'macro_clear', t, testcount, '', \ clear_cfunc testcount += 1
def test_4_html(self): """Testing the Html() macro""" print "\nTesting the Html() macro" log.info("Testing the Html() macro") testlist = [ "\n".join( [ gen_texts(words, [], [], [], tc=5, pc=0, ec=0, lc=0, mc=0, hc=0, fc=0, nopipe=True) for j in range(randint(0, 10)) ] ) for k in range(100) ] html_macros = [ [ '{{ Html("<table><tr><td>hello world</td></tr></table>") }}', ["<table><tr><td>hello world</td></tr></table>"], ] ] def html_cfunc(macro_ref): def cfunc(ref, tu): html = tu.tohtml() [assert_true(r in html, "Fail Html Macro : %s " % html) for r in macro_ref] return cfunc testcount = 1 for t in testlist: off = randint(0, len(t)) m = choice(html_macros) t = t[:off] + m[0] + t[off:] yield self._test_execute, "macro_html", t, testcount, "", html_cfunc(m[1]) testcount += 1
def test_1_clear(self): """Testing the Clear() macro""" print "\nTesting the Clear() macro" log.info("Testing the Clear() macro") testlist = [ "\n".join( [ gen_texts(words, [], [], [], tc=5, pc=0, ec=0, lc=0, mc=0, hc=0, fc=0, nopipe=True) for j in range(randint(0, 10)) ] ) for k in range(100) ] clear_macros = ["{{ Clear() }}", "{{Clear() }}", "{{ Clear() }}"] def clear_cfunc(ref, tu): html = tu.tohtml() assert_true('class="etm-clear"' in html, "Fail Clear Macro : %s " % html) testcount = 1 for t in testlist: off = randint(0, len(t)) t = t.replace("{", "") t = t.replace("}", "") t = t[:off] + choice(clear_macros) + t[off:] yield self._test_execute, "macro_clear", t, testcount, "", clear_cfunc testcount += 1
def test_3_redirect(self): """Testing the Redirect() macro""" print "\nTesting the Redirect() macro" log.info("Testing the Redirect() macro") testlist = [ "\n".join( [ gen_texts(words, [], [], [], tc=5, pc=0, ec=0, lc=0, mc=0, hc=0, fc=0, nopipe=True) for j in range(randint(0, 10)) ] ) for k in range(100) ] redirect_macros = [ ['{{ Redirect("Hello World") }}', ["Hello World"]], ['{{ Redirect("/") }}', ["/"]], ['{{ Redirect("/hello/world") }}', ["/hello/world"]], ] def redirect_cfunc(macro_ref): def cfunc(ref, tu): tu.tohtml() [assert_true(r == tu.parser.etparser.redirect, "Fail Redirect Macro") for r in macro_ref] return cfunc testcount = 1 for t in testlist: m = choice(redirect_macros) t = m[0] + t yield self._test_execute, "macro_redirect", t, testcount, "", redirect_cfunc(m[1]) testcount += 1
def test_A_textlines(self): """Testing textlines""" print "\nTesting textlines" log.info("Testing textlines") testlist = [ '\n'.join([ gen_texts( words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=1, nopipe=True ) for j in range(randint(0,10)) ]) + gen_psep(randint(0,3)) for i in range(100) ] +\ [ '\n'.join([ gen_texts( words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=0, nopipe=True ) for j in range(randint(0,10)) ]) + choice(ETMARKUP) + ' ' + '\n'.join([ gen_texts( words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=0, nopipe=True ) for j in range(randint(0,10)) ]) + choice(ETMARKUP) + ' ' '\n'.join([ gen_texts( words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=0, nopipe=True ) for j in range(randint(0,10)) ]) for i in range(10) ] testcount = 1 for t in testlist: yield self._test_execute, 'textlines', t, testcount testcount += 1
def test_A_textlines( self ) : """Testing textlines""" print "\nTesting textlines" log.info( "Testing textlines" ) testlist = [ '\n'.join([ gen_texts( words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=1, nopipe=True ) for j in range(randint(0,10)) ]) + gen_psep(randint(0,3)) for i in range(100) ] +\ [ '\n'.join([ gen_texts( words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=0, nopipe=True ) for j in range(randint(0,10)) ]) + choice(ETMARKUP) + ' ' + '\n'.join([ gen_texts( words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=0, nopipe=True ) for j in range(randint(0,10)) ]) + choice(ETMARKUP) + ' ' '\n'.join([ gen_texts( words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=0, nopipe=True ) for j in range(randint(0,10)) ]) for i in range(10) ] testcount = 1 for t in testlist : yield self._test_execute, 'textlines', t, testcount testcount += 1
def test_G_definitions(self): """Testing definitions""" print "\nTesting definitions" log.info("Testing definitions") testlist = [ '\n'.join([ gen_defnmark() + \ gen_texts( words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=1, nopipe=True ) for j in range(randint(0,10)) ]) + gen_psep(randint(0,3)) for i in range(100) ] testcount = 1 for t in testlist: yield self._test_execute, 'definitions', t, testcount testcount += 1
def btablemultiline(firstline): rem = '\n'.join([ gen_texts(words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=1, nopipe=True) for i in range(0, 3) ]) return firstline + rem
def test_G_definitions( self ) : """Testing definitions""" print "\nTesting definitions" log.info( "Testing definitions" ) testlist = [ '\n'.join([ gen_defnmark() + \ gen_texts( words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=1, nopipe=True ) for j in range(randint(0,10)) ]) + gen_psep(randint(0,3)) for i in range(100) ] testcount = 1 for t in testlist : yield self._test_execute, 'definitions', t, testcount testcount += 1
def test_2_span(self): """Testing the Span() macro""" print "\nTesting the Span() macro" log.info("Testing the Span() macro") testlist = [ "\n".join( [ gen_texts(words, [], [], [], tc=5, pc=0, ec=0, lc=0, mc=0, hc=0, fc=0, nopipe=True) for j in range(randint(0, 10)) ] ) for k in range(100) ] span_macros = [ ['{{ Span("Hello World") }}', ["Hello World"]], ['{{ Span("How are you") }}', ["How are you"]], ['{{ Span("With style", style={ "font-weight" : "bold"} ) }}', ["With style", "font-weight: bold"]], ['{{ Span("With kw styles", color="blue") }}', ["With kw styles", "color: blue"]], ] def span_cfunc(macro_ref): def cfunc(ref, tu): html = tu.tohtml() [ assert_true(r in html and 'class="etm-span"' in html, "Fail Span Macro : %s " % html) for r in macro_ref ] return cfunc testcount = 1 for t in testlist: off = randint(0, len(t)) m = choice(span_macros) t = t[:off] + m[0] + t[off:] yield self._test_execute, "macro_span", t, testcount, "", span_cfunc(m[1]) testcount += 1
def test_5_toc( self ) : """Testing the Toc() macro""" print "\nTesting the Toc() macro" log.info( "Testing the Toc() macro" ) testlist = [ '\n'.join([ gen_texts( words, [], [], [], tc=5, pc=0, ec=0, lc=0, mc=0, hc=0, fc=0, nopipe=True ) for j in range(randint(0,10)) ]) for k in range(100) ] toc_macros = [ '{{ Toc( indent=1 ) }}', '{{Toc() }}', '{{ Toc( indent=2 ) }}' ] testcount = 1 def toc_cfunc( ref, tu ) : html= tu.tohtml() assert_true( 'class="toc"' in html, 'Fail Toc Macro : %s ' % html ) for t in testlist : t = choice( toc_macros ) + t yield self._test_execute, 'macro_toc', t, testcount, '', \ toc_cfunc testcount += 1
def test_2_span( self ) : """Testing the Span() macro""" print "\nTesting the Span() macro" log.info( "Testing the Span() macro" ) testlist = [ '\n'.join([ gen_texts( words, [], [], [], tc=5, pc=0, ec=0, lc=0, mc=0, hc=0, fc=0, nopipe=True ) for j in range(randint(0,10)) ]) for k in range(100) ] span_macros = [ [ '{{ Span("Hello World") }}', [ 'Hello World' ] ], [ '{{ Span("How are you") }}', [ 'How are you' ] ], [ '{{ Span("With style", style={ "font-weight" : "bold"} ) }}', [ 'With style', 'font-weight: bold' ] ] , [ '{{ Span("With kw styles", color="blue") }}', [ 'With kw styles', 'color: blue' ] ] ] def span_cfunc( macro_ref ) : def cfunc( ref, tu ) : html= tu.tohtml() [ assert_true( r in html and 'class="etm-span"' in html, 'Fail Span Macro : %s ' % html ) for r in macro_ref ] return cfunc testcount = 1 for t in testlist : off = randint( 0, len(t) ) m = choice( span_macros ) t = t[:off] + m[0] + t[off:] yield self._test_execute, 'macro_span', t, testcount, '', \ span_cfunc( m[1] ) testcount += 1
def test_5_toc(self): """Testing the Toc() macro""" print "\nTesting the Toc() macro" log.info("Testing the Toc() macro") testlist = [ "\n".join( [ gen_texts(words, [], [], [], tc=5, pc=0, ec=0, lc=0, mc=0, hc=0, fc=0, nopipe=True) for j in range(randint(0, 10)) ] ) for k in range(100) ] toc_macros = ["{{ Toc( indent=1 ) }}", "{{Toc() }}", "{{ Toc( indent=2 ) }}"] testcount = 1 def toc_cfunc(ref, tu): html = tu.tohtml() assert_true('class="toc"' in html, "Fail Toc Macro : %s " % html) for t in testlist: t = choice(toc_macros) + t yield self._test_execute, "macro_toc", t, testcount, "", toc_cfunc testcount += 1
def btablemultiline( firstline ) : rem = '\n'.join([ gen_texts( words, links, macros, htmls, tc=5, pc=1, ec=2, lc=1, mc=1, hc=1, fc=1, nopipe=True ) for i in range(0,3) ]) return firstline + rem