This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
test_grokadmin.py
66 lines (52 loc) · 1.63 KB
/
test_grokadmin.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
# -*- coding: utf-8 -*-
import doctest
import os
import unittest
import zope.component.eventtesting
from pkg_resources import resource_listdir
from zope.testing import cleanup
def setUpZope(test):
zope.component.eventtesting.setUp(test)
def cleanUpZope(test):
cleanup.cleanUp()
def suiteFromPackage(name):
files = resource_listdir(__name__, name)
suite = unittest.TestSuite()
for filename in files:
if not filename.endswith('.py'):
continue
if filename.endswith('_fixture.py'):
continue
if filename == '__init__.py':
continue
dottedname = 'grokui.admin.tests.%s.%s' % (name, filename[:-3])
test = doctest.DocTestSuite(
dottedname,
setUp=setUpZope,
tearDown=cleanUpZope,
optionflags=(doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE),
)
suite.addTest(test)
return suite
def pnorm(path):
"""Normalization of paths to use forward slashes. This is needed
to make sure the tests work on windows.
"""
return path.replace(os.sep, '/')
def test_suite():
suite = unittest.TestSuite()
globs = {'pnorm': pnorm}
for name in []:
suite.addTest(suiteFromPackage(name))
for name in ['utilities.py']:
suite.addTest(doctest.DocFileSuite(
name,
package='grokui.admin',
globs=globs,
setUp=setUpZope,
tearDown=cleanUpZope,
optionflags=(doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE),
))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')