tests.py 1.89 KB
Newer Older
Jim Fulton's avatar
Jim Fulton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
##############################################################################
#
# Copyright (c) 2006 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################

import os, re, shutil, sys, tempfile
import pkg_resources
import zc.buildout.testing
18
import zc.recipe.egg
Jim Fulton's avatar
Jim Fulton committed
19 20

import unittest
21
import zope.testing
Jim Fulton's avatar
Jim Fulton committed
22
from zope.testing import doctest, renormalizing
Jim Fulton's avatar
Jim Fulton committed
23 24 25 26 27 28 29 30

def dirname(d, level=1):
    if level == 0:
        return d
    return dirname(os.path.dirname(d), level-1)

def setUp(test):
    zc.buildout.testing.buildoutSetUp(test)
31 32 33
    zc.buildout.testing.install_develop('zc.recipe.testrunner', test)
    zc.buildout.testing.install_develop('zc.recipe.egg', test)
    zc.buildout.testing.install('zope.testing', test)
Jim Fulton's avatar
Jim Fulton committed
34 35 36 37 38 39

def test_suite():
    return unittest.TestSuite((
        #doctest.DocTestSuite(),
        doctest.DocFileSuite(
            'README.txt',
40
            setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
Jim Fulton's avatar
Jim Fulton committed
41
            checker=renormalizing.RENormalizing([
42 43 44
               zc.buildout.testing.normalize_path,
               zc.buildout.testing.normalize_script,
               zc.buildout.testing.normalize_egg_py,        
45
               (re.compile('#!\S+python\S*'), '#!python'),
46 47
               (re.compile('\d[.]\d+ seconds'), '0.001 seconds'),
               (re.compile('zope.testing-[^-]+-'), 'zope.testing-X-'),
Jim Fulton's avatar
Jim Fulton committed
48
               ])
Jim Fulton's avatar
Jim Fulton committed
49 50 51 52 53 54
            ),
        
        ))

if __name__ == '__main__':
    unittest.main(defaultTest='test_suite')