/usr/share/pyshared/zope/app/broken/tests.py is in python-zope.app.broken 3.6.0-0ubuntu3.
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 | ##############################################################################
#
# 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.
#
##############################################################################
"""Broken-object tests
$Id: tests.py 116913 2010-09-25 13:31:51Z icemac $
"""
import unittest
from doctest import DocTestSuite
def test_annotations():
"""Broken objects may have attribute annotations
If they do, we can access them::
>>> from zope.app.broken.broken import Broken
>>> b = Broken()
>>> b.__setstate__({'__annotations__': {'foo.bar': 42}})
>>> b['foo.bar']
42
>>> b.get('foo.bar')
42
Missing keys are handled as expected:
>>> b['foo.baz']
Traceback (most recent call last):
...
KeyError: 'foo.baz'
>>> b.get('foo.baz')
It is an error to modify annotations:
>>> b['foo.baz'] = []
Traceback (most recent call last):
...
BrokenModified: Can't modify broken objects
>>> del b['foo.bar']
Traceback (most recent call last):
...
BrokenModified: Can't modify broken objects
If there are no annotation data, then, obviously, there are no annotations:
>>> b = Broken()
>>> b['foo.bar']
Traceback (most recent call last):
...
KeyError: 'foo.bar'
>>> b.get('foo.bar')
>>> b['foo.bar'] = []
Traceback (most recent call last):
...
BrokenModified: Can't modify broken objects
>>> del b['foo.bar']
Traceback (most recent call last):
...
BrokenModified: Can't modify broken objects
Cleanup:
>>> import ZODB.broken
>>> ZODB.broken.broken_cache.clear()
"""
def test_suite():
return unittest.TestSuite((
DocTestSuite(),
DocTestSuite('zope.app.broken.broken'),
))
if __name__ == '__main__': unittest.main()
|