This file is indexed.

/usr/share/pyshared/RestrictedPython/tests/testUtiliities.py is in python-restrictedpython 3.6.0-0ubuntu4.

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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
##############################################################################
#
# Copyright (c) 2009 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.
#
##############################################################################
"""Run tests in README.txt
"""
import unittest

class UtilitiesTests(unittest.TestCase):

    def test_string_in_utility_builtins(self):
        import string
        from RestrictedPython.Utilities import utility_builtins
        self.failUnless(utility_builtins['string'] is string)

    def test_math_in_utility_builtins(self):
        import math
        from RestrictedPython.Utilities import utility_builtins
        self.failUnless(utility_builtins['math'] is math)

    def test_whrandom_in_utility_builtins(self):
        import random
        from RestrictedPython.Utilities import utility_builtins
        self.failUnless(utility_builtins['whrandom'] is random)

    def test_random_in_utility_builtins(self):
        import random
        from RestrictedPython.Utilities import utility_builtins
        self.failUnless(utility_builtins['random'] is random)

    def test_sets_in_utility_builtins_if_importable(self):
        import warnings
        from RestrictedPython.Utilities import utility_builtins
        _old_filters = warnings.filters[:]
        warnings.filterwarnings('ignore', category=DeprecationWarning)
        try:
            try:
                import sets
            except ImportError:
                sets = None
        finally:
            warnings.filters[:] = _old_filters
        self.failUnless(utility_builtins['sets'] is sets)

    def test_DateTime_in_utility_builtins_if_importable(self):
        try:
            import DateTime
        except ImportError:
            pass
        else:
            from RestrictedPython.Utilities import utility_builtins
            self.failUnless('DateTime' in utility_builtins)

    def test_same_type_in_utility_builtins(self):
        from RestrictedPython.Utilities import same_type
        from RestrictedPython.Utilities import utility_builtins
        self.failUnless(utility_builtins['same_type'] is same_type)

    def test_test_in_utility_builtins(self):
        from RestrictedPython.Utilities import test
        from RestrictedPython.Utilities import utility_builtins
        self.failUnless(utility_builtins['test'] is test)

    def test_reorder_in_utility_builtins(self):
        from RestrictedPython.Utilities import reorder
        from RestrictedPython.Utilities import utility_builtins
        self.failUnless(utility_builtins['reorder'] is reorder)

    def test_sametype_only_one_arg(self):
        from RestrictedPython.Utilities import same_type
        self.failUnless(same_type(object()))

    def test_sametype_only_two_args_same(self):
        from RestrictedPython.Utilities import same_type
        self.failUnless(same_type(object(), object()))

    def test_sametype_only_two_args_different(self):
        from RestrictedPython.Utilities import same_type
        class Foo(object):
            pass
        self.failIf(same_type(object(), Foo()))

    def test_sametype_only_multiple_args_same(self):
        from RestrictedPython.Utilities import same_type
        self.failUnless(same_type(object(), object(), object(), object()))

    def test_sametype_only_multipe_args_one_different(self):
        from RestrictedPython.Utilities import same_type
        class Foo(object):
            pass
        self.failIf(same_type(object(), object(), Foo()))

    def test_test_single_value_true(self):
        from RestrictedPython.Utilities import test
        self.failUnless(test(True))

    def test_test_single_value_False(self):
        from RestrictedPython.Utilities import test
        self.failIf(test(False))

    def test_test_even_values_first_true(self):
        from RestrictedPython.Utilities import test
        self.assertEqual(test(True, 'first', True, 'second'), 'first')

    def test_test_even_values_not_first_true(self):
        from RestrictedPython.Utilities import test
        self.assertEqual(test(False, 'first', True, 'second'), 'second')

    def test_test_odd_values_first_true(self):
        from RestrictedPython.Utilities import test
        self.assertEqual(test(True, 'first', True, 'second', False), 'first')

    def test_test_odd_values_not_first_true(self):
        from RestrictedPython.Utilities import test
        self.assertEqual(test(False, 'first', True, 'second', False), 'second')

    def test_test_odd_values_last_true(self):
        from RestrictedPython.Utilities import test
        self.assertEqual(test(False, 'first', False, 'second', 'third'),
                         'third')

    def test_test_odd_values_last_false(self):
        from RestrictedPython.Utilities import test
        self.assertEqual(test(False, 'first', False, 'second', False), False)

    def test_reorder_with__None(self):
        from RestrictedPython.Utilities import reorder
        before = ['a', 'b', 'c', 'd', 'e']
        without = ['a', 'c', 'e']
        after = reorder(before, without=without)
        self.assertEqual(after, [('b', 'b'), ('d', 'd')])

    def test_reorder_with__not_None(self):
        from RestrictedPython.Utilities import reorder
        before = ['a', 'b', 'c', 'd', 'e']
        with_ = ['a', 'd']
        without = ['a', 'c', 'e']
        after = reorder(before, with_=with_, without=without)
        self.assertEqual(after, [('d', 'd')])

def test_suite():
    return unittest.TestSuite((
        unittest.makeSuite(UtilitiesTests),
        ))

if __name__ == '__main__':
    unittest.main(defaultTest='test_suite')