/usr/lib/python2.7/dist-packages/zope/configuration/tests/test_docutils.py is in python-zope.configuration 4.0.3-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | ##############################################################################
#
# Copyright (c) 2003 Zope Foundation 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 for zope.configuration.docutils
"""
import unittest
class Test_wrap(unittest.TestCase):
def _callFUT(self, *args, **kw):
from zope.configuration.docutils import wrap
return wrap(*args, **kw)
def test_empty(self):
self.assertEqual(self._callFUT(''), '\n\n')
def test_only_whitespace(self):
self.assertEqual(self._callFUT(' \t\n\r'), '\n\n')
def test_single_paragraphs(self):
self.assertEqual(
self._callFUT('abcde fghij klmno pqrst uvwxy', 10, 3),
' abcde\n fghij\n klmno\n pqrst\n uvwxy\n\n')
def test_multiple_paragraphs(self):
self.assertEqual(
self._callFUT('abcde fghij klmno\n\npqrst uvwxy', 10, 3),
' abcde\n fghij\n klmno\n\n pqrst\n uvwxy\n\n')
class Test_makeDocStructures(unittest.TestCase):
def _callFUT(self, *args, **kw):
from zope.configuration.docutils import makeDocStructures
return makeDocStructures(*args, **kw)
def _makeContext(self):
class _Context(object):
def __init__(self):
self._docRegistry = []
return _Context()
def test_empty(self):
context = self._makeContext()
namespaces, subdirs = self._callFUT(context)
self.assertEqual(len(namespaces), 0)
self.assertEqual(len(subdirs), 0)
def test_wo_parents(self):
from zope.interface import Interface
class ISchema(Interface):
pass
class IUsedIn(Interface):
pass
NS = 'http://namespace.example.com/main'
NS2 = 'http://namespace.example.com/other'
def _one():
pass
def _two():
pass
def _three():
pass
context = self._makeContext()
context._docRegistry.append(
((NS, 'one'), ISchema, IUsedIn, _one, 'ONE', None))
context._docRegistry.append(
((NS2, 'two'), ISchema, IUsedIn, _two, 'TWO', None))
context._docRegistry.append(
((NS, 'three'), ISchema, IUsedIn, _three, 'THREE', None))
namespaces, subdirs = self._callFUT(context)
self.assertEqual(len(namespaces), 2)
self.assertEqual(namespaces[NS], {'one': (ISchema, _one, 'ONE'),
'three': (ISchema, _three, 'THREE')})
self.assertEqual(namespaces[NS2], {'two': (ISchema, _two, 'TWO')})
self.assertEqual(len(subdirs), 0)
def test_w_parents(self):
from zope.interface import Interface
class ISchema(Interface):
pass
class IUsedIn(Interface):
pass
PNS = 'http://namespace.example.com/parent'
NS = 'http://namespace.example.com/main'
NS2 = 'http://namespace.example.com/other'
def _one():
pass
def _two():
pass
def _three():
pass
class Parent(object):
namespace = PNS
name = 'parent'
parent1 = Parent()
parent2 = Parent()
parent2.name = 'parent2'
context = self._makeContext()
context._docRegistry.append(
((NS, 'one'), ISchema, IUsedIn, _one, 'ONE', parent1))
context._docRegistry.append(
((NS2, 'two'), ISchema, IUsedIn, _two, 'TWO', parent2))
context._docRegistry.append(
((NS, 'three'), ISchema, IUsedIn, _three, 'THREE', parent1))
namespaces, subdirs = self._callFUT(context)
self.assertEqual(len(namespaces), 0)
self.assertEqual(len(subdirs), 2)
self.assertEqual(subdirs[(PNS, 'parent')],
[(NS, 'one', ISchema, _one, 'ONE'),
(NS, 'three', ISchema, _three, 'THREE')])
self.assertEqual(subdirs[(PNS, 'parent2')],
[(NS2, 'two', ISchema, _two, 'TWO')])
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(Test_wrap),
unittest.makeSuite(Test_makeDocStructures),
))
|