-
Notifications
You must be signed in to change notification settings - Fork 13
/
tests.py
65 lines (60 loc) · 2.51 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
##############################################################################
# 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.
#
##############################################################################
"""Tests for the testing framework.
"""
import doctest
import sys
import re
import unittest
from zope.testing import renormalizing
from zope.testing.test_renormalizing import Exception2To3
def print_(*args):
sys.stdout.write(' '.join(map(str, args))+'\n')
def setUp(test):
test.globs['print_'] = print_
def test_suite():
suite = unittest.TestSuite((
doctest.DocFileSuite(
'module.txt',
# Python 3.3 changed exception messaging:
# https://bugs.launchpad.net/zope.testing/+bug/1055720
# and then Python 3.6 introduced ImportError subclasses
checker=renormalizing.RENormalizing([
(re.compile('ModuleNotFoundError:'), 'ImportError:'),
(re.compile(
"No module named '?zope.testing.unlikelymodulename'?"),
'No module named unlikelymodulename'),
(re.compile("No module named '?fake'?"),
'No module named fake')])),
doctest.DocFileSuite('loggingsupport.txt', setUp=setUp),
doctest.DocFileSuite('renormalizing.txt', setUp=setUp),
doctest.DocFileSuite('setupstack.txt', setUp=setUp),
doctest.DocFileSuite(
'wait.txt', setUp=setUp,
checker=renormalizing.RENormalizing([
# For Python 3.4.
(re.compile('zope.testing.wait.TimeOutWaitingFor: '),
'TimeOutWaitingFor: '),
# For Python 3.5
(re.compile('zope.testing.wait.Wait.TimeOutWaitingFor: '),
'TimeOutWaitingFor: '),
])
),
))
if sys.version_info[:2] >= (2, 7):
suite.addTests(doctest.DocFileSuite('doctestcase.txt'))
if sys.version_info[0] < 3:
suite.addTests(doctest.DocTestSuite('zope.testing.server'))
suite.addTests(doctest.DocFileSuite('formparser.txt'))
suite.addTest(
unittest.makeSuite(Exception2To3))
return suite