-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
executable file
·100 lines (85 loc) · 4.04 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
##############################################################################
#
# Copyright (c) 2004 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.
#
##############################################################################
"""Tests for the Interface Documentation Module
$Id: tests.py 39722 2005-10-29 23:25:40Z srichter $
"""
from pprint import PrettyPrinter
import unittest
from zope.component.interfaces import IFactory
from zope.interface import implements
from zope.testing import doctest, doctestunit
from zope.app.traversing.interfaces import IContainmentRoot
from zope.app.location import LocationProxy
from zope.app.testing import placelesssetup, ztapi, setup
from zope.app.renderer.rest import ReStructuredTextSourceFactory
from zope.app.renderer.rest import IReStructuredTextSource
from zope.app.renderer.rest import ReStructuredTextToHTMLRenderer
def setUp(test):
placelesssetup.setUp()
# Register Renderer Components
ztapi.provideUtility(IFactory, ReStructuredTextSourceFactory,
'zope.source.rest')
ztapi.browserView(IReStructuredTextSource, '',
ReStructuredTextToHTMLRenderer)
# Cheat and register the ReST renderer as the STX one as well.
ztapi.provideUtility(IFactory, ReStructuredTextSourceFactory,
'zope.source.stx')
ztapi.browserView(IReStructuredTextSource, '',
ReStructuredTextToHTMLRenderer)
setup.setUpTestAsModule(test, 'zope.app.apidoc.doctest')
def tearDown(test):
placelesssetup.tearDown()
setup.tearDownTestAsModule(test)
# Generally useful classes and functions
class Root:
implements(IContainmentRoot)
__parent__ = None
__name__ = ''
def rootLocation(obj, name):
return LocationProxy(obj, Root(), name)
def test_suite():
return unittest.TestSuite((
doctest.DocTestSuite('zope.app.apidoc.browser.apidoc',
setUp=setUp, tearDown=placelesssetup.tearDown),
doctest.DocFileSuite('README.txt',
setUp=setUp,
tearDown=placelesssetup.tearDown,
globs={'pprint': doctestunit.pprint},
optionflags=doctest.NORMALIZE_WHITESPACE),
doctest.DocFileSuite('classregistry.txt',
globs={'pprint': doctestunit.pprint},
optionflags=doctest.NORMALIZE_WHITESPACE),
doctest.DocFileSuite('interface.txt',
setUp=setUp,
tearDown=placelesssetup.tearDown,
globs={'pprint': doctestunit.pprint},
optionflags=doctest.NORMALIZE_WHITESPACE),
doctest.DocFileSuite('component.txt',
setUp=setUp,
tearDown=placelesssetup.tearDown,
globs={'pprint': doctestunit.pprint},
optionflags=doctest.NORMALIZE_WHITESPACE),
doctest.DocFileSuite('presentation.txt',
setUp=placelesssetup.setUp,
tearDown=placelesssetup.tearDown,
globs={'pprint': doctestunit.pprint},
optionflags=doctest.NORMALIZE_WHITESPACE),
doctest.DocFileSuite('utilities.txt',
setUp=setUp,
tearDown=placelesssetup.tearDown,
globs={'pprint': doctestunit.pprint},
optionflags=doctest.NORMALIZE_WHITESPACE),
))
if __name__ == '__main__':
unittest.main(default="test_suite")