tests/test_lib_utils.py
author robin <robin@reportlab.com>
Tue, 07 Mar 2017 10:00:34 +0000
changeset 4330 617ffa6bbdc8
parent 4252 fe660f227cac
child 4336 d39c63b164bc
permissions -rw-r--r--
changes for release 3.4.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4330
617ffa6bbdc8 changes for release 3.4.0
robin <robin@reportlab.com>
parents: 4252
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2017
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
     2
#see license.txt for license details
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
     3
"""Tests for reportlab.lib.utils
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
     4
"""
4252
fe660f227cac changes for release 3.3.0
robin
parents: 4238
diff changeset
     5
__version__='3.3.0'
2987
711910106e3a tests: more changes to testsFolder and friends
rgbecker
parents: 2984
diff changeset
     6
from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, printLocation
2984
c63f149d55aa tests.utils --> reportlab.lib.testutils
rgbecker
parents: 2966
diff changeset
     7
setOutDir(__name__)
4009
3a501628abb0 test_lib_utils.py: hack fix with sleep for Mac rubbish
robin
parents: 3905
diff changeset
     8
import os, time, sys
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
     9
import reportlab
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
    10
import unittest
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    11
from reportlab.lib import colors
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    12
from reportlab.lib.utils import recursiveImport, recursiveGetAttr, recursiveSetAttr, rl_isfile, \
4238
169d06f37b25 fix test for pypy
robin
parents: 4091
diff changeset
    13
                                isCompactDistro, isPy3, isPyPy
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    14
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
    15
def _rel_open_and_read(fn):
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
    16
    from reportlab.lib.utils import open_and_read
2987
711910106e3a tests: more changes to testsFolder and friends
rgbecker
parents: 2984
diff changeset
    17
    from reportlab.lib.testutils import testsFolder
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
    18
    cwd = os.getcwd()
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
    19
    os.chdir(testsFolder)
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
    20
    try:
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
    21
        return open_and_read(fn)
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
    22
    finally:
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
    23
        os.chdir(cwd)
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
    24
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    25
class ImporterTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    26
    "Test import utilities"
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    27
    count = 0
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    28
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    29
    def setUp(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    30
        from reportlab.lib.utils import get_rl_tempdir
4009
3a501628abb0 test_lib_utils.py: hack fix with sleep for Mac rubbish
robin
parents: 3905
diff changeset
    31
        s = repr(int(time.time())) + repr(self.count)
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    32
        self.__class__.count += 1
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    33
        self._tempdir = get_rl_tempdir('reportlab_test','tmp_%s' % s)
3905
3481c76bdcdf test_lib_utils.py: fix the temporary folder creation
robin
parents: 3823
diff changeset
    34
        if not os.path.isdir(self._tempdir):
3481c76bdcdf test_lib_utils.py: fix the temporary folder creation
robin
parents: 3823
diff changeset
    35
            os.makedirs(self._tempdir,0o700)
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    36
        _testmodulename = os.path.join(self._tempdir,'test_module_%s.py' % s)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    37
        f = open(_testmodulename,'w')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    38
        f.write('__all__=[]\n')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    39
        f.close()
4009
3a501628abb0 test_lib_utils.py: hack fix with sleep for Mac rubbish
robin
parents: 3905
diff changeset
    40
        if sys.platform=='darwin' and isPy3:
3a501628abb0 test_lib_utils.py: hack fix with sleep for Mac rubbish
robin
parents: 3905
diff changeset
    41
            time.sleep(0.3)
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    42
        self._testmodulename = os.path.splitext(os.path.basename(_testmodulename))[0]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    43
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    44
    def tearDown(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    45
        from shutil import rmtree
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    46
        rmtree(self._tempdir,1)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    47
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    48
    def test1(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    49
        "try stuff known to be in the path"
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    50
        m1 = recursiveImport('reportlab.pdfgen.canvas')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    51
        import reportlab.pdfgen.canvas
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    52
        assert m1 == reportlab.pdfgen.canvas
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    53
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    54
    def test2(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    55
        "try under a well known directory NOT on the path"
2987
711910106e3a tests: more changes to testsFolder and friends
rgbecker
parents: 2984
diff changeset
    56
        from reportlab.lib.testutils import testsFolder
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
    57
        D = os.path.join(testsFolder,'..','tools','pythonpoint')
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    58
        fn = os.path.join(D,'stdparser.py')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    59
        if rl_isfile(fn) or rl_isfile(fn+'c') or rl_isfile(fn+'o'):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    60
            m1 = recursiveImport('stdparser', baseDir=D)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    61
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    62
    def test3(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    63
        "ensure CWD is on the path"
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    64
        try:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    65
            cwd = os.getcwd()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    66
            os.chdir(self._tempdir)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    67
            m1 = recursiveImport(self._testmodulename)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    68
        finally:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    69
            os.chdir(cwd)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    70
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    71
    def test4(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    72
        "ensure noCWD removes current dir from path"
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    73
        try:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    74
            cwd = os.getcwd()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    75
            os.chdir(self._tempdir)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    76
            import sys
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    77
            try:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    78
                del sys.modules[self._testmodulename]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    79
            except KeyError:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    80
                pass
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    81
            self.assertRaises(ImportError,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    82
                              recursiveImport,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    83
                              self._testmodulename,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    84
                              noCWD=1)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    85
        finally:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    86
            os.chdir(cwd)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    87
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    88
    def test5(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    89
        "recursive attribute setting/getting on modules"
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    90
        import reportlab.lib.units
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    91
        inch = recursiveGetAttr(reportlab, 'lib.units.inch')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    92
        assert inch == 72
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    93
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    94
        recursiveSetAttr(reportlab, 'lib.units.cubit', 18*inch)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    95
        cubit = recursiveGetAttr(reportlab, 'lib.units.cubit')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    96
        assert cubit == 18*inch
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    97
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    98
    def test6(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    99
        "recursive attribute setting/getting on drawings"
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   100
        from reportlab.graphics.charts.barcharts import sampleH1
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   101
        drawing = sampleH1()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   102
        recursiveSetAttr(drawing, 'barchart.valueAxis.valueMax', 72)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   103
        theMax = recursiveGetAttr(drawing, 'barchart.valueAxis.valueMax')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   104
        assert theMax == 72
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   105
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   106
    def test7(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   107
        "test open and read of a simple relative file"
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   108
        b = _rel_open_and_read('../docs/images/Edit_Prefs.gif')
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   109
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   110
    def test8(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   111
        "test open and read of a relative file: URL"
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   112
        b = _rel_open_and_read('file:../docs/images/Edit_Prefs.gif')
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   113
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   114
    def test9(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   115
        "test open and read of an http: URL"
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   116
        from reportlab.lib.utils import open_and_read
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   117
        b = open_and_read('http://www.reportlab.com/rsrc/encryption.gif')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   118
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   119
    def test10(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   120
        "test open and read of a simple relative file"
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3668
diff changeset
   121
        from reportlab.lib.utils import open_and_read, getBytesIO
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3668
diff changeset
   122
        b = getBytesIO(_rel_open_and_read('../docs/images/Edit_Prefs.gif'))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   123
        b = open_and_read(b)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   124
4091
2ee37be22e45 utils.py: allow data: scheme in open_for_read and test in test_lib_utils; bump version to 3.1.11
robin
parents: 4009
diff changeset
   125
    def test11(self):
2ee37be22e45 utils.py: allow data: scheme in open_for_read and test in test_lib_utils; bump version to 3.1.11
robin
parents: 4009
diff changeset
   126
        "test open and read of an RFC 2397 data URI with base64 encoding"
2ee37be22e45 utils.py: allow data: scheme in open_for_read and test in test_lib_utils; bump version to 3.1.11
robin
parents: 4009
diff changeset
   127
        result = _rel_open_and_read('data:image/gif;base64,R0lGODdhAQABAIAAAP///////ywAAAAAAQABAAACAkQBADs=')
2ee37be22e45 utils.py: allow data: scheme in open_for_read and test in test_lib_utils; bump version to 3.1.11
robin
parents: 4009
diff changeset
   128
        self.assertEquals(result,b'GIF87a\x01\x00\x01\x00\x80\x00\x00\xff\xff\xff\xff\xff\xff,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;')
2ee37be22e45 utils.py: allow data: scheme in open_for_read and test in test_lib_utils; bump version to 3.1.11
robin
parents: 4009
diff changeset
   129
2ee37be22e45 utils.py: allow data: scheme in open_for_read and test in test_lib_utils; bump version to 3.1.11
robin
parents: 4009
diff changeset
   130
    def test12(self):
2ee37be22e45 utils.py: allow data: scheme in open_for_read and test in test_lib_utils; bump version to 3.1.11
robin
parents: 4009
diff changeset
   131
        "test open and read of an RFC 2397 data URI without an encoding"
2ee37be22e45 utils.py: allow data: scheme in open_for_read and test in test_lib_utils; bump version to 3.1.11
robin
parents: 4009
diff changeset
   132
        result = _rel_open_and_read('data:text/plain;,Hello%20World')
2ee37be22e45 utils.py: allow data: scheme in open_for_read and test in test_lib_utils; bump version to 3.1.11
robin
parents: 4009
diff changeset
   133
        self.assertEquals(result,b'Hello World')
3668
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   134
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   135
    def testRecursiveImportErrors(self):
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   136
        "check we get useful error messages"
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   137
        try:
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   138
            m1 = recursiveImport('reportlab.pdfgen.brush')
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   139
            self.fail("Imported a nonexistent module")
3823
c8133d91487a fix utils tests and small changes to recursiveImport
robin
parents: 3723
diff changeset
   140
        except ImportError as e:
4009
3a501628abb0 test_lib_utils.py: hack fix with sleep for Mac rubbish
robin
parents: 3905
diff changeset
   141
            self.assertIn('reportlab.pdfgen.brush',str(e))
3668
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   142
            
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   143
        try:
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   144
            m1 = recursiveImport('totally.non.existent')
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   145
            self.fail("Imported a nonexistent module")
3823
c8133d91487a fix utils tests and small changes to recursiveImport
robin
parents: 3723
diff changeset
   146
        except ImportError as e:
4009
3a501628abb0 test_lib_utils.py: hack fix with sleep for Mac rubbish
robin
parents: 3905
diff changeset
   147
            self.assertIn('totally',str(e))
3668
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   148
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   149
        try:
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   150
            #import a module in the 'tests' directory with a bug
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   151
            m1 = recursiveImport('unimportable')
d8a42e00c079 recursiveImport now has much more helpful error messages
Andy Robinson <andy@reportlab.com>
parents: 3617
diff changeset
   152
            self.fail("Imported a buggy module")
4009
3a501628abb0 test_lib_utils.py: hack fix with sleep for Mac rubbish
robin
parents: 3905
diff changeset
   153
        except Exception as e:
4238
169d06f37b25 fix test for pypy
robin
parents: 4091
diff changeset
   154
            self.assertIn(("integer division by zeroException raised while importing 'unimportable': integer division by zero"
169d06f37b25 fix test for pypy
robin
parents: 4091
diff changeset
   155
                            if isPyPy 
169d06f37b25 fix test for pypy
robin
parents: 4091
diff changeset
   156
                            else ('division by zero' if isPy3
169d06f37b25 fix test for pypy
robin
parents: 4091
diff changeset
   157
                                 else 'integer division or modulo by zero'))
169d06f37b25 fix test for pypy
robin
parents: 4091
diff changeset
   158
                        ,str(e))
169d06f37b25 fix test for pypy
robin
parents: 4091
diff changeset
   159
 
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   160
def makeSuite():
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   161
    return makeSuiteForClasses(ImporterTestCase)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   162
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   163
if __name__ == "__main__": #noruntests
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   164
    unittest.TextTestRunner().run(makeSuite())
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   165
    printLocation()