"Fossies" - the Fresh Open Source Software Archive

Member "reportlab-3.5.23/tests/test_platypus_lists.py" (31 May 2019, 10708 Bytes) of package /linux/privat/reportlab-3.5.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "test_platypus_lists.py": 3.5.19_vs_3.5.20.

    1 from random import randint
    2 from xml.sax.saxutils import escape as xmlEscape
    3 from reportlab import xrange
    4 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
    5 setOutDir(__name__)
    6 import os,unittest
    7 from reportlab.platypus import Spacer, SimpleDocTemplate, Table, TableStyle, ListFlowable, ListItem, \
    8         Paragraph, PageBreak, DDIndenter, MultiCol
    9 from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
   10 from reportlab.lib.units import inch, cm
   11 from reportlab.lib.utils import simpleSplit
   12 from reportlab.lib import colors
   13 from reportlab.lib import randomtext
   14 
   15 TEXTS=[
   16 '''We have already seen that the notion of level of grammaticalness is,
   17 apparently, determined by a corpus of utterance tokens upon which
   18 conformity has been defined by the paired utterance test.  If the
   19 position of the trace in (99c) were only relatively inaccessible to
   20 movement, a descriptively adequate grammar suffices to account for the
   21 traditional practice of grammarians.  Notice, incidentally, that this
   22 analysis of a formative as a pair of sets of features cannot be
   23 arbitrary in the strong generative capacity of the theory.''',
   24 '''
   25 Of course, the systematic use of complex symbols raises serious doubts
   26 about a stipulation to place the constructions into these various
   27 categories.  By combining adjunctions and certain deformations, the
   28 natural general principle that will subsume this case is to be regarded
   29 as a descriptive fact.  This suggests that this analysis of a formative
   30 as a pair of sets of features suffices to account for the requirement
   31 that branching is not tolerated within the dominance scope of a complex
   32 symbol.''',
   33 '''In the discussion of resumptive pronouns following (81), this
   34 selectionally introduced contextual feature is to be regarded as a
   35 parasitic gap construction.  With this clarification, the systematic use
   36 of complex symbols is not to be considered in determining a descriptive
   37 fact.  On our assumptions, the notion of level of grammaticalness is
   38 necessary to impose an interpretation on the strong generative capacity
   39 of the theory.  It appears that a descriptively adequate grammar is not
   40 subject to the requirement that branching is not tolerated within the
   41 dominance scope of a complex symbol.  Comparing these examples with
   42 their parasitic gap counterparts in (96) and (97), we see that this
   43 selectionally introduced contextual feature is rather different from a
   44 parasitic gap construction.''',
   45 '''
   46 Blah blah blah blah blah blah discipline?... naked? ... With a melon!? blah blah blah blah blah Very silly indeed Mr. Nesbitt has learned the first lesson of 'Not Being Seen', not to stand up. blah blah blah Would you like a twist of lemming sir?. 
   47 ''',
   48 '''
   49 Blah blah blah multidisciplinary blah blah blah blah blah blah blah blah blah blah blah. Blah blah blah conceptualize blah contribution blah blah blah blah blah blah blah blah blah blah blah blah proactive. Blah blah blah blah blah blah proactive blah mastery learning blah blah blah blah blah projection Total Quality Management blah. 
   50 ''',
   51 '''
   52 Blah Archer IV blah blah blah blah blah blah blah asteroid field USS Enterprise quantum flux blah blah Pacifica blah blah blah blah blah asteroid field. Blah blah K'Vort Class Bird-of-Prey battle bridge blah blah blah Bolian blah blah Dr. Pulaski blah blah blah blah. 
   53 ''',
   54 '''
   55 Blah blah blah Rexx blah RFC822-compliant blah blah ...went into "yo-yo mode" blah blah blah blah blah blah security blah DOS Unix blah blah blah. Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah Virtual Reality Modeling Language blah blah blah blah blah. 
   56 ''',
   57 ]
   58 
   59 class ListsTestCase(unittest.TestCase):
   60     "Make documents with tables"
   61 
   62     def test1(self):
   63         styleSheet = getSampleStyleSheet()
   64         doc = SimpleDocTemplate(outputfile('test_platypus_lists1.pdf'),showBoundary=True)
   65         story=[]
   66         sty = [ ('GRID',(0,0),(-1,-1),1,colors.green),
   67             ('BOX',(0,0),(-1,-1),2,colors.red),
   68             ]
   69         normal = styleSheet['BodyText']
   70         bold = normal.clone('bold',fontName='Helvetica-Bold')
   71         lpSty = normal.clone('lpSty',spaceAfter=18)
   72         data = [[str(i+1), Paragraph("xx "* (i%10), styleSheet["BodyText"]), Paragraph(("blah "*(i%40)), normal)] for i in xrange(5)]
   73         data1 = [[str(i+1), Paragraph(["zz ","yy "][i]*(i+3), styleSheet["BodyText"]), Paragraph(("duh  "*(i+3)), normal)] for i in xrange(2)]
   74         OL = ListFlowable(
   75             [
   76             Paragraph("A table with 5 rows", lpSty),
   77             Table(data, style=sty, colWidths = [50,100,200]),
   78             ListItem(
   79                 Paragraph("A sublist", normal),
   80                 value=7,
   81                 ),
   82             ListFlowable(
   83                     [
   84                     Paragraph("Another table with 3 rows", normal),
   85                     Table(data[:3], style=sty, colWidths = [60,90,180]),
   86                     Paragraph(TEXTS[0], normal),
   87                     ],
   88                     bulletType='i',
   89                     ),
   90             Paragraph("An unordered sublist", normal),
   91             ListFlowable(
   92                     [
   93                     Paragraph("A table with 2 rows", normal),
   94                     ListItem(Table(data1, style=sty, colWidths = [60,90,180]),bulletColor='green'),
   95                     ListItem(Paragraph(TEXTS[2], normal),bulletColor='red',value='square')
   96                     ],
   97                     bulletType='bullet',
   98                     start='circle',
   99                     ),
  100             Paragraph(TEXTS[1], normal),
  101             ])
  102 
  103         story.append(OL)
  104         
  105         
  106         story.append(PageBreak())
  107         story.append(Paragraph("Now try a list with a very long URL in it.  Without splitting the long word it used to be that this can push out the right page margin", normal))
  108         OL = ListFlowable(
  109             [
  110             Paragraph(TEXTS[1], normal),
  111             Paragraph('''For details about pairing the smart card reader with the Android device, refer to the baiMobile specification: 
  112 <a href="http://www.biometricassociates.com/downloads/user-guides/baiMobile-3000MP-User-Guide-for-Android-v2.0.pdf" color="blue">http://www.biometricassociates.com/downloads/user-guides/make-the-url-even-longer/baiMobile-3000MP-User-Guide-for-Android-v2.0.pdf</a>.''', normal),
  113             
  114             Paragraph(TEXTS[1], normal),
  115             ])
  116 
  117         story.append(OL)
  118 
  119         story.append(Paragraph("Same as above with a simple paragraph for the long word", normal))
  120         OL = ListFlowable(
  121             [
  122             Paragraph(TEXTS[1], normal),
  123             Paragraph('''For details about pairing the smart card reader with the Android device, refer to the baiMobile specification: 
  124 http://www.biometricassociates.com/downloads/user-guides/make-the-url-even-longer/baiMobile-3000MP-User-Guide-for-Android-v2.0.pdf.''', normal),
  125             Paragraph(TEXTS[1], normal),
  126             ])
  127         story.append(OL)
  128 
  129         story.append(Paragraph("Same as above with a simple unicode paragraph for the long word", normal))
  130         OL = ListFlowable(
  131             [
  132             Paragraph(TEXTS[1], normal),
  133             Paragraph(u'''For details about pairing the smart card reader with the Android device, refer to the baiMobile specification: 
  134 http://www.biometricassociates.com/downloads/user-guides/make-the-url-even-longer/baiMobile-3000MP-User-Guide-for-Android-v2.0.pdf.''', normal),
  135             Paragraph(TEXTS[1], normal),
  136             ])
  137         story.append(OL)
  138 
  139         story.append(
  140             ListFlowable(
  141                     [
  142                     Paragraph("Level 0.1", normal),
  143                     Paragraph("Level 0.2", normal),
  144                     ListFlowable(
  145                             [
  146                             Paragraph("Level 1.1", normal),
  147                             Paragraph("Level 1.1", normal),
  148                             ListFlowable(
  149                                     [
  150                                     Paragraph("Level 2.1", normal),
  151                                     Paragraph("Level 2.1", normal),
  152                                     Paragraph("Level 2.3", normal),
  153                                     ],
  154                                 ),
  155                             Paragraph("Level 1.4", normal),
  156                             ],
  157                         ),
  158                     Paragraph("Level 0.4", normal),
  159                     ],
  160                     bulletType='1',
  161                     start='10',
  162                     ),
  163             )
  164         
  165         story.append(PageBreak())
  166         story.append(Paragraph("DDIndenter", style=normal))
  167         story.append(Paragraph("Coffee",style=bold))
  168         story.append(DDIndenter(Paragraph("Black hot drink",style=normal),leftIndent=36))
  169         story.append(Paragraph("Milk",style=bold))
  170         story.append(DDIndenter(Paragraph("White cold drink",style=normal),leftIndent=36))
  171         story.append(Paragraph("Whiskey",style=bold))
  172         story.append(DDIndenter(Paragraph("A nice alcoholic drink",style=normal),leftIndent=36))
  173         story.append(PageBreak())
  174         story.append(Paragraph("MultiCol", style=normal))
  175         RT = 'STARTUP COMPUTERS BLAH BUZZWORD STARTREK PRINTING PYTHON CHOMSKY CHOMSKY'.split()
  176         for i in xrange(5):
  177             topic = RT[randint(0,len(RT)-1)]
  178             np = randint(2,6)
  179             story.append(
  180                     MultiCol([
  181                         [Paragraph('Column %d' % (i+1,),style=bold)],
  182                         [],
  183                         [Paragraph(xmlEscape(randomtext.randomText(topic,randint(1,7))),style=normal) for j in xrange(np)]
  184                         ],
  185                         widths=['20%',3,'80%'],
  186                         )
  187                     )
  188 
  189         story.append(PageBreak())
  190         story.append(Paragraph("MultiCol 2", style=normal))
  191         for i in xrange(5):
  192             topic = RT[randint(0,len(RT)-1)]
  193             np = randint(2,6)
  194             story.append(
  195                     MultiCol([
  196                         ([Paragraph('Column %d' % (i+1,),style=bold)]+
  197                         [Paragraph(xmlEscape(randomtext.randomText(topic,randint(1,7))),style=normal) for j in xrange(np)]),
  198                         [],
  199                         [Paragraph(xmlEscape(randomtext.randomText(topic,randint(1,7))),style=normal) for j in xrange(np)]
  200                         ],
  201                         widths=['50%',5,'50%'],
  202                         )
  203                     )
  204         
  205         doc.build(story)
  206 
  207 def makeSuite():
  208     return makeSuiteForClasses(ListsTestCase)
  209 
  210 #noruntests
  211 if __name__ == "__main__":
  212     unittest.TextTestRunner().run(makeSuite())
  213     printLocation()