tests/test_geomutils.py
author robin <robin@reportlab.com>
Tue, 07 Mar 2017 10:00:34 +0000
changeset 4330 617ffa6bbdc8
parent 4252 fe660f227cac
permissions -rw-r--r--
changes for release 3.4.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3042
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
     1
#!/bin/env python
4330
617ffa6bbdc8 changes for release 3.4.0
robin <robin@reportlab.com>
parents: 4252
diff changeset
     2
#Copyright ReportLab Europe Ltd. 2000-2017
3042
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
     3
#see license.txt for license details
4252
fe660f227cac changes for release 3.3.0
robin
parents: 3617
diff changeset
     4
__version__='3.3.0'
3042
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
     5
__doc__="""Tests for geometry utility functions."""
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
     6
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
     7
import unittest
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
     8
from reportlab.lib.testutils import setOutDir,makeSuiteForClasses
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
     9
setOutDir(__name__)
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    10
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    11
class GeomTestCase(unittest.TestCase):
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    12
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    13
    def test_padding(self):
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    14
        "Test reportlab.lib.boxstuff.normalizePadding."
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    15
        from reportlab.lib.geomutils import normalizeTRBL
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    16
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    17
        paddings = (
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    18
            (4, (4, 4, 4, 4)),
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    19
            ((0, 1), (0, 1, 0, 1)),
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    20
            ((0, 1, 2), (0, 1, 2, 1)),
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    21
            ((0, 1, 2, 3), (0, 1, 2, 3)),
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    22
        )
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    23
        
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    24
        for pin, pout in paddings:
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    25
            pres = normalizeTRBL(pin)
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    26
            assert pres == pout, "normalizeTRBL(%s) returned %s, expected %s" % (pin, pres, pout)
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    27
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    28
def makeSuite():
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    29
    return makeSuiteForClasses(GeomTestCase)
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    30
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    31
if __name__ == "__main__":
2ae512e69843 Implemented variable padding for platypus paragraphs.
jonas
parents:
diff changeset
    32
    unittest.TextTestRunner().run(makeSuite())