reportlab/test/test_platypus_paragraphs.py
author rgbecker
Fri, 26 Jan 2007 12:46:22 +0000
changeset 2742 8edd54153201
parent 2735 70cf084e5811
child 2744 9472eedb9702
permissions -rw-r--r--
paraparser: allow <a> as alias for <link>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2332
2a7ab4405e18 Remove $Header:, fix CopyRight & history
rgbecker
parents: 2268
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2004
817
8c3a399effda License text changes
rgbecker
parents: 763
diff changeset
     2
#see license.txt for license details
2332
2a7ab4405e18 Remove $Header:, fix CopyRight & history
rgbecker
parents: 2268
diff changeset
     3
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/test/test_platypus_paragraphs.py
646
82c8a12841b2 Added doc strings.
dinu_gherman
parents: 639
diff changeset
     4
"""Tests for the reportlab.platypus.paragraphs module.
82c8a12841b2 Added doc strings.
dinu_gherman
parents: 639
diff changeset
     5
"""
82c8a12841b2 Added doc strings.
dinu_gherman
parents: 639
diff changeset
     6
2267
e02203404549 Remove unwanted import
rgbecker
parents: 2250
diff changeset
     7
import sys, os
639
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
     8
from string import split, strip, join, whitespace
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
     9
from operator import truth
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    10
from types import StringType, ListType
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    11
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    12
from reportlab.test import unittest
2708
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
    13
from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation, outputfile
1667
dfe2f821f4e2 Slightly refactored test suite to do the same thing with less code.
dinu_gherman
parents: 1440
diff changeset
    14
639
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    15
from reportlab.pdfbase.pdfmetrics import stringWidth
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    16
from reportlab.platypus.paraparser import ParaParser
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    17
from reportlab.platypus.flowables import Flowable
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    18
from reportlab.lib.colors import Color
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    19
from reportlab.lib.units import cm
639
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    20
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    21
from reportlab.lib.utils import _className
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    22
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    23
from reportlab.platypus.paragraph import Paragraph
2735
70cf084e5811 reportlab: fix justification space counting bug and improve tests
rgbecker
parents: 2733
diff changeset
    24
from reportlab.platypus.frames import Frame, ShowBoundaryValue
2662
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
    25
from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate, PageBreak, NextPageTemplate
753
155af19db555 Fixed imports for non-trailing digit modules.
dinu_gherman
parents: 686
diff changeset
    26
from reportlab.platypus import tableofcontents
1440
243d35446390 Removed 0 from multiBuild stuff prior to further changes;
andy_robinson
parents: 817
diff changeset
    27
from reportlab.platypus.tableofcontents import TableOfContents
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    28
from reportlab.platypus.tables import TableStyle, Table
639
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    29
from reportlab.platypus.paragraph import *
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    30
from reportlab.platypus.paragraph import _getFragWords
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
    31
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    32
def myMainPageFrame(canvas, doc):
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    33
    "The page frame used for all PDF documents."
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1667
diff changeset
    34
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    35
    canvas.saveState()
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    36
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    37
    canvas.rect(2.5*cm, 2.5*cm, 15*cm, 25*cm)
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    38
    canvas.setFont('Times-Roman', 12)
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    39
    pageNumber = canvas.getPageNumber()
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    40
    canvas.drawString(10*cm, cm, str(pageNumber))
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    41
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    42
    canvas.restoreState()
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1667
diff changeset
    43
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    44
class MyDocTemplate(BaseDocTemplate):
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    45
    _invalidInitArgs = ('pageTemplates',)
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1667
diff changeset
    46
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    47
    def __init__(self, filename, **kw):
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    48
        frame1 = Frame(2.5*cm, 2.5*cm, 15*cm, 25*cm, id='F1')
2662
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
    49
        frame2 = Frame(2.5*cm, 2.5*cm, 310, 25*cm, id='F2')
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    50
        self.allowSplitting = 0
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    51
        apply(BaseDocTemplate.__init__, (self, filename), kw)
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    52
        template = PageTemplate('normal', [frame1], myMainPageFrame)
2662
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
    53
        template1 = PageTemplate('special', [frame2], myMainPageFrame)
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
    54
        self.addPageTemplates([template,template1])
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    55
2410
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    56
class ParagraphCorners(unittest.TestCase):
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    57
    "some corner cases which should parse"
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    58
    def check(text,bt = getSampleStyleSheet()['BodyText']):
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    59
        try:
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    60
            P = Paragraph(text,st)
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    61
        except:
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    62
            raise AssertionError("'%s' should parse"%text)
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    63
            
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    64
    def test0(self):
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    65
        self.check('<para />')
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    66
        self.check('<para/>')
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    67
        self.check('\t\t\t\n\n\n<para />')
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    68
        self.check('\t\t\t\n\n\n<para/>')
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    69
        self.check('<para\t\t\t\t/>')
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    70
        self.check('<para></para>')
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    71
        self.check('<para>      </para>')
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    72
        self.check('\t\t\n\t\t\t   <para>      </para>')
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2332
diff changeset
    73
        
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    74
class ParagraphSplitTestCase(unittest.TestCase):
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    75
    "Test multi-page splitting of paragraphs (eyeball-test)."
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1667
diff changeset
    76
1667
dfe2f821f4e2 Slightly refactored test suite to do the same thing with less code.
dinu_gherman
parents: 1440
diff changeset
    77
    def test0(self):
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    78
        "This makes one long multi-page paragraph."
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    79
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    80
        # Build story.
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    81
        story = []
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    82
        styleSheet = getSampleStyleSheet()
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
    83
        bt = styleSheet['BodyText']
1767
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    84
        text = '''If you imagine that the box of X's tothe left is
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    85
an image, what I want to be able to do is flow a
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    86
series of paragraphs around the image
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    87
so that once the bottom of the image is reached, then text will flow back to the
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    88
left margin. I know that it would be possible to something like this
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    89
using tables, but I can't see how to have a generic solution.
1771
105572a4222f Whitespace and tab character cleanup
andy_robinson
parents: 1767
diff changeset
    90
There are two examples of this in the demonstration section of the reportlab
1767
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    91
site.
1771
105572a4222f Whitespace and tab character cleanup
andy_robinson
parents: 1767
diff changeset
    92
If you look at the "minimal" euro python conference brochure, at the end of the
105572a4222f Whitespace and tab character cleanup
andy_robinson
parents: 1767
diff changeset
    93
timetable section (page 8), there are adverts for "AdSu" and "O'Reilly". I can
1767
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    94
see how the AdSu one might be done generically, but the O'Reilly, unsure...
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    95
I guess I'm hoping that I've missed something, and that
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    96
it's actually easy to do using platypus.
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    97
'''
0417dea6ed28 Added test of ParagraphAndImage
rgbecker
parents: 1683
diff changeset
    98
        from reportlab.platypus.flowables import ParagraphAndImage, Image
2250
ffa5bc439092 Now works in compact distro
rgbecker
parents: 1771
diff changeset
    99
        from reportlab.lib.utils import _RL_DIR
ffa5bc439092 Now works in compact distro
rgbecker
parents: 1771
diff changeset
   100
        gif = os.path.join(_RL_DIR,'test','pythonpowered.gif')
ffa5bc439092 Now works in compact distro
rgbecker
parents: 1771
diff changeset
   101
        story.append(ParagraphAndImage(Paragraph(text,bt),Image(gif)))
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
   102
        phrase = 'This should be a paragraph spanning at least three pages. '
2561
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   103
        description = ''.join([('%d: '%i)+phrase for i in xrange(250)])
2557
d84c18fb377f added _offsets handling to paragraph for flow around on left side
rgbecker
parents: 2505
diff changeset
   104
        story.append(ParagraphAndImage(Paragraph(description, bt),Image(gif),side='left'))
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
   105
2561
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   106
        doc = MyDocTemplate(outputfile('test_platypus_paragraphandimage.pdf'))
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   107
        doc.multiBuild(story)
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   108
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   109
    def test1(self):
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   110
        "This makes one long multi-page paragraph."
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   111
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   112
        # Build story.
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   113
        story = []
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   114
        styleSheet = getSampleStyleSheet()
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   115
        h3 = styleSheet['Heading3']
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   116
        bt = styleSheet['BodyText']
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   117
        text = '''If you imagine that the box of X's tothe left is
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   118
an image, what I want to be able to do is flow a
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   119
series of paragraphs around the image
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   120
so that once the bottom of the image is reached, then text will flow back to the
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   121
left margin. I know that it would be possible to something like this
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   122
using tables, but I can't see how to have a generic solution.
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   123
There are two examples of this in the demonstration section of the reportlab
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   124
site.
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   125
If you look at the "minimal" euro python conference brochure, at the end of the
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   126
timetable section (page 8), there are adverts for "AdSu" and "O'Reilly". I can
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   127
see how the AdSu one might be done generically, but the O'Reilly, unsure...
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   128
I guess I'm hoping that I've missed something, and that
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2562
diff changeset
   129
it's actually easy to do using platypus.We can do greek letters <greek>mDngG</greek>. This should be a
2594
746800f5caf9 reportlab: fix up links in paragraphs
rgbecker
parents: 2585
diff changeset
   130
u with a dieresis on top &lt;unichar code=0xfc/&gt;="<unichar code=0xfc/>" and this &amp;#xfc;="&#xfc;" and this \\xc3\\xbc="\xc3\xbc". On the other hand this
2742
8edd54153201 paraparser: allow <a> as alias for <link>
rgbecker
parents: 2735
diff changeset
   131
should be a pound sign &amp;pound;="&pound;" and this an alpha &amp;alpha;="&alpha;". You can have links in the page <link href=http://www.reportlab.com color=blue>ReportLab</link> &amp; <a href=http://www.reportlab.org color=green>ReportLab.org</a>.
2594
746800f5caf9 reportlab: fix up links in paragraphs
rgbecker
parents: 2585
diff changeset
   132
Use scheme "pdf:" to indicate an external PDF link, "http:", "https:" to indicate an external link eg something to open in
2644
e762ad1c8909 reportlab: add support for strike through
rgbecker
parents: 2594
diff changeset
   133
your browser. If an internal link begins with something that looks like a scheme, precede with "document:". <strike>This text should have a strike through it.</strike>
2561
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   134
'''
2562
3c77a70414d9 platypus: ImagesAndFlowables in final form
rgbecker
parents: 2561
diff changeset
   135
        from reportlab.platypus.flowables import ImageAndFlowables, Image
2561
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   136
        from reportlab.lib.utils import _RL_DIR
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   137
        gif = os.path.join(_RL_DIR,'test','pythonpowered.gif')
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   138
        heading = Paragraph('This is a heading',h3)
2562
3c77a70414d9 platypus: ImagesAndFlowables in final form
rgbecker
parents: 2561
diff changeset
   139
        story.append(ImageAndFlowables(Image(gif),[heading,Paragraph(text,bt)]))
2561
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   140
        phrase = 'This should be a paragraph spanning at least three pages. '
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   141
        description = ''.join([('%d: '%i)+phrase for i in xrange(250)])
2562
3c77a70414d9 platypus: ImagesAndFlowables in final form
rgbecker
parents: 2561
diff changeset
   142
        story.append(ImageAndFlowables(Image(gif),[heading,Paragraph(description, bt)],imageSide='left'))
2662
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   143
        story.append(NextPageTemplate('special'))
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   144
        story.append(PageBreak())
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   145
        story.append(ImageAndFlowables(
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   146
                        Image(gif,width=280,height=120),
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   147
                        Paragraph('''The concept of an integrated one box solution for advanced voice and
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   148
data applications began with the introduction of the IMACS. The
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   149
IMACS 200 carries on that tradition with an integrated solution
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   150
optimized for smaller port size applications that the IMACS could not
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   151
economically address. An array of the most popular interfaces and
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   152
features from the IMACS has been bundled into a small 2U chassis
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   153
providing the ultimate in ease of installation.''',
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   154
                        style=ParagraphStyle(
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   155
                                name="base",
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   156
                                fontName="Helvetica",
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   157
                                leading=12,
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   158
                                leftIndent=0,
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   159
                                firstLineIndent=0,
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   160
                                spaceBefore = 9.5,
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   161
                                fontSize=9.5,
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   162
                                )
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   163
                            ),
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   164
                    imageSide='left',
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   165
                    )
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   166
                )
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   167
        story.append(ImageAndFlowables(
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   168
                        Image(gif,width=240,height=120),
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   169
                        Paragraph('''The concept of an integrated one box solution for advanced voice and
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   170
data applications began with the introduction of the IMACS. The
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   171
IMACS 200 carries on that tradition with an integrated solution
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   172
optimized for smaller port size applications that the IMACS could not
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   173
economically address. An array of the most popular interfaces and
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   174
features from the IMACS has been bundled into a small 2U chassis
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   175
providing the ultimate in ease of installation.''',
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   176
                        style=ParagraphStyle(
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   177
                                name="base",
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   178
                                fontName="Helvetica",
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   179
                                leading=12,
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   180
                                leftIndent=0,
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   181
                                firstLineIndent=0,
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   182
                                spaceBefore = 9.5,
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   183
                                fontSize=9.5,
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   184
                                )
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   185
                            ),
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   186
                    imageSide='left',
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   187
                    )
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   188
                )
2561
a2409b6627e6 reportlab: added FlowablesAndImage
rgbecker
parents: 2557
diff changeset
   189
2662
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   190
        
0a5217162c3f fix narrow space case for ImageAndFlowables
rgbecker
parents: 2644
diff changeset
   191
        doc = MyDocTemplate(outputfile('test_platypus_imageandflowables.pdf'),showBoundary=1)
1440
243d35446390 Removed 0 from multiBuild stuff prior to further changes;
andy_robinson
parents: 817
diff changeset
   192
        doc.multiBuild(story)
686
17c6f15386e0 Added a multi-page paragraph test.
dinu_gherman
parents: 646
diff changeset
   193
639
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   194
class FragmentTestCase(unittest.TestCase):
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   195
    "Test fragmentation of paragraphs."
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1667
diff changeset
   196
1667
dfe2f821f4e2 Slightly refactored test suite to do the same thing with less code.
dinu_gherman
parents: 1440
diff changeset
   197
    def test0(self):
639
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   198
        "Test empty paragraph."
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   199
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   200
        styleSheet = getSampleStyleSheet()
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   201
        B = styleSheet['BodyText']
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   202
        text = ''
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   203
        P = Paragraph(text, B)
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   204
        frags = map(lambda f:f.text, P.frags)
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   205
        assert frags == []
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   206
1667
dfe2f821f4e2 Slightly refactored test suite to do the same thing with less code.
dinu_gherman
parents: 1440
diff changeset
   207
    def test1(self):
639
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   208
        "Test simple paragraph."
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   209
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   210
        styleSheet = getSampleStyleSheet()
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   211
        B = styleSheet['BodyText']
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   212
        text = "X<font name=Courier>Y</font>Z"
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   213
        P = Paragraph(text, B)
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   214
        frags = map(lambda f:f.text, P.frags)
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   215
        assert frags == ['X', 'Y', 'Z']
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   216
2733
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   217
class ULTestCase(unittest.TestCase):
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   218
    "Test underlining and overstriking of paragraphs."
2708
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   219
    def testUl(self):
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   220
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   221
        from reportlab.lib.units import inch
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   222
        class MyDocTemplate(BaseDocTemplate):
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   223
            _invalidInitArgs = ('pageTemplates',)
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   224
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   225
            def __init__(self, filename, **kw):
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   226
                self.allowSplitting = 0
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   227
                kw['showBoundary']=1
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   228
                BaseDocTemplate.__init__(self, filename, **kw)
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   229
                self.addPageTemplates(
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   230
                        [
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   231
                        PageTemplate('normal',
2735
70cf084e5811 reportlab: fix justification space counting bug and improve tests
rgbecker
parents: 2733
diff changeset
   232
                                [Frame(inch, inch, 6.27*inch, 9.69*inch, id='first',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red"))],
2708
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   233
                                ),
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   234
                        ])
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   235
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   236
        styleSheet = getSampleStyleSheet()
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   237
        normal = ParagraphStyle(name='normal',fontName='Times-Roman',fontSize=12,leading=1.2*12,parent=styleSheet['Normal'])
2733
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   238
        normal_sp = ParagraphStyle(name='normal_sp',parent=normal,alignment=TA_JUSTIFY,spaceBefore=12)
2708
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   239
        normal_just = ParagraphStyle(name='normal_just',parent=normal,alignment=TA_JUSTIFY)
2733
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   240
        normal_right = ParagraphStyle(name='normal_right',parent=normal,alignment=TA_RIGHT)
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   241
        normal_center = ParagraphStyle(name='normal_center',parent=normal,alignment=TA_CENTER)
2708
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   242
        normal_indent = ParagraphStyle(name='normal_indent',firstLineIndent=0.5*inch,parent=normal)
2733
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   243
        normal_indent_lv_2 = ParagraphStyle(name='normal_indent_lv_2',firstLineIndent=1.0*inch,parent=normal)
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   244
        texts = ['''Furthermore, a subset of English sentences interesting on quite
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   245
independent grounds is not quite equivalent to a stipulation to place
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   246
the constructions into these various categories.''',
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   247
        '''We will bring evidence in favor of
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   248
The following thesis:  most of the methodological work in modern
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   249
linguistics can be defined in such a way as to impose problems of
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   250
phonemic and morphological analysis.''']
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   251
        story =[]
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   252
        a = story.append
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   253
        for mode in (0,1):
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   254
            text0 = texts[0]
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   255
            text1 = texts[1]
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   256
            if mode:
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   257
                text0 = text0.replace('English sentences','<b>English sentences</b>').replace('quite equivalent','<i>quite equivalent</i>')
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   258
                text1 = text1.replace('the methodological work','<b>the methodological work</b>').replace('to impose problems','<i>to impose problems</i>')
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   259
            for t in ('u','strike'):
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   260
                for n in xrange(6):
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   261
                    for s in (normal,normal_center,normal_right,normal_just,normal_indent, normal_indent_lv_2):
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   262
                        a(Paragraph('n=%d style=%s tag=%s'%(n,s.name,t),style=normal_sp))
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   263
                        a(Paragraph('%s<%s>%s</%s>. %s <%s>%s</%s>. %s' % (
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   264
                        (s==normal_indent_lv_2 and '<seq id="document" inc="no"/>.<seq id="document_lv_2"/>' or ''),
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   265
                        t,' '.join((n+1)*['A']),t,text0,t,' '.join((n+1)*['A']),t,text1),
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   266
                        style=s))
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   267
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_ul.pdf'))
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   268
        doc.build(story)
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   269
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   270
class JustifyTestCase(unittest.TestCase):
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   271
    "Test justification of paragraphs."
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   272
    def testUl(self):
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   273
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   274
        from reportlab.lib.units import inch
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   275
        class MyDocTemplate(BaseDocTemplate):
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   276
            _invalidInitArgs = ('pageTemplates',)
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   277
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   278
            def __init__(self, filename, **kw):
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   279
                self.allowSplitting = 0
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   280
                BaseDocTemplate.__init__(self, filename, **kw)
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   281
                self.addPageTemplates(
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   282
                        [
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   283
                        PageTemplate('normal',
2735
70cf084e5811 reportlab: fix justification space counting bug and improve tests
rgbecker
parents: 2733
diff changeset
   284
                                [Frame(inch, inch, 6.27*inch, 9.69*inch, id='first',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red"))],
2733
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   285
                                ),
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   286
                        ])
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   287
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   288
        styleSheet = getSampleStyleSheet()
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   289
        normal = ParagraphStyle(name='normal',fontName='Times-Roman',fontSize=12,leading=1.2*12,parent=styleSheet['Normal'])
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   290
        normal_sp = ParagraphStyle(name='normal_sp',parent=normal,alignment=TA_JUSTIFY,spaceBefore=12)
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   291
        normal_just = ParagraphStyle(name='normal_just',parent=normal,alignment=TA_JUSTIFY,spaceAfter=12)
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   292
        normal_right = ParagraphStyle(name='normal_right',parent=normal,alignment=TA_RIGHT)
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   293
        normal_center = ParagraphStyle(name='normal_center',parent=normal,alignment=TA_CENTER)
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   294
        normal_indent = ParagraphStyle(name='normal_indent',firstLineIndent=0.5*inch,parent=normal)
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   295
        normal_indent_lv_2 = ParagraphStyle(name='normal_indent_lv_2',firstLineIndent=1.0*inch,parent=normal)
2708
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   296
        text0 = '''Furthermore, a subset of English sentences interesting on quite
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   297
independent grounds is not quite equivalent to a stipulation to place
2733
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   298
the constructions into these various categories. We will bring evidence in favor of
2708
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   299
The following thesis:  most of the methodological work in modern
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   300
linguistics can be defined in such a way as to impose problems of
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   301
phonemic and morphological analysis.'''
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   302
        story =[]
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   303
        a = story.append
2733
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   304
        for mode in (0,1,2,3):
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   305
            text = text0
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   306
            if mode==1:
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   307
                text = text.replace('English sentences','<b>English sentences</b>').replace('quite equivalent','<i>quite equivalent</i>')
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   308
                text = text.replace('the methodological work','<b>the methodological work</b>').replace('to impose problems','<i>to impose problems</i>')
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   309
                a(Paragraph('Justified paragraph in normal/bold/italic font',style=normal))
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   310
            elif mode==2:
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   311
                text = '<b>%s</b>' % text
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   312
                a(Paragraph('Justified paragraph in bold font',style=normal))
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   313
            elif mode==3:
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   314
                text = '<i>%s</i>' % text
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   315
                a(Paragraph('Justified paragraph in italic font',style=normal))
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   316
            else:
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   317
                a(Paragraph('Justified paragraph in normal font',style=normal))
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   318
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   319
            a(Paragraph(text,style=normal_just))
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   320
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_just.pdf'))
2708
13619490e003 paragraph.py: fix underlining position errors
rgbecker
parents: 2662
diff changeset
   321
        doc.build(story)
639
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   322
1667
dfe2f821f4e2 Slightly refactored test suite to do the same thing with less code.
dinu_gherman
parents: 1440
diff changeset
   323
#noruntests
639
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   324
def makeSuite():
2733
5395da969892 test_platypus_paragraphs.py: add tests for justification
rgbecker
parents: 2708
diff changeset
   325
    return makeSuiteForClasses(FragmentTestCase, ParagraphSplitTestCase, ULTestCase, JustifyTestCase)
639
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   326
763
2755ba5be930 Added utils\runtests.py inhibitor comment
rgbecker
parents: 753
diff changeset
   327
#noruntests
639
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   328
if __name__ == "__main__":
ca024e564629 Initial checkin.
dinu_gherman
parents:
diff changeset
   329
    unittest.TextTestRunner().run(makeSuite())
2505
0859d48c2558 reportlab/test: fix so individual tests print output folder location
rgbecker
parents: 2410
diff changeset
   330
    printLocation()