/usr/share/pyshared/ZConfig/components/basic/tests/test_mapping.py is in python-zconfig 2.9.3-0ubuntu1.
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 | ##############################################################################
#
# 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 of the 'basic' section types provided as part of
ZConfig.components.basic."""
import ZConfig.tests.support
import unittest
SIMPLE_SCHEMA = '''\
<schema>
<import package="ZConfig.components.basic" file="mapping.xml" />
<sectiontype name="dict"
extends="ZConfig.basic.mapping" />
<sectiontype name="intkeys"
extends="ZConfig.basic.mapping"
keytype="integer" />
<section name="*"
type="dict"
attribute="simple_dict" />
<section name="*"
type="intkeys"
attribute="int_dict" />
</schema>
'''
class BasicSectionTypeTestCase(
ZConfig.tests.support.TestHelper, unittest.TestCase):
schema = None
def setUp(self):
if self.schema is None:
self.__class__.schema = self.load_schema_text(SIMPLE_SCHEMA)
def test_simple_empty_dict(self):
conf = self.load_config_text(self.schema, "<dict/>")
self.assertEqual(conf.simple_dict, {})
conf = self.load_config_text(self.schema, """\
<dict foo>
# comment
</dict>
""")
self.assertEqual(conf.simple_dict, {})
def test_simple_dict(self):
conf = self.load_config_text(self.schema, """\
<dict foo>
key-one value-one
key-two value-two
</dict>
""")
L = conf.simple_dict.items()
L.sort()
self.assertEqual(L, [("key-one", "value-one"),
("key-two", "value-two")])
def test_derived_dict(self):
conf = self.load_config_text(self.schema, """\
<intkeys>
1 foo
2 bar
42 question?
</intkeys>
""")
L = conf.int_dict.items()
L.sort()
self.assertEqual(L, [(1, "foo"), (2, "bar"), (42, "question?")])
def test_suite():
return unittest.makeSuite(BasicSectionTypeTestCase)
|