This file is indexed.

/usr/lib/python2.7/dist-packages/nose2/tests/functional/test_loading.py is in python-nose2 0.5.0-1.

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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
"""
pkg1
pkg1.test
pkg1.test.test_things
pkg1.test.test_things.test_func
pkg1.test.test_things.test_gen
pkg1.test.test_things.test_gen:3
pkg1.test.test_things.SomeTests
pkg1.test.test_things.SomeTests.test_ok

# generator method
# generator method index

# param func
# param func index
# param method
# param method index

"""
from nose2.tests._common import FunctionalTestCase, support_file


class TestLoadTestsFromPackage(FunctionalTestCase):

    def test_module_name(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things')
        self.assertTestRunOutputMatches(proc, stderr='Ran 25 tests')
        self.assertEqual(proc.poll(), 1)

    def test_package_name(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1')
        self.assertTestRunOutputMatches(proc, stderr='Ran 25 tests')
        self.assertEqual(proc.poll(), 1)

    def test_module_name_with_start_dir(self):
        proc = self.runIn(
            '.', '-v', '-s', support_file('scenario/tests_in_package'),
            'pkg1.test.test_things')

        self.assertTestRunOutputMatches(proc, stderr='Ran 25 tests')
        self.assertEqual(proc.poll(), 1)

    def test_package_name_with_start_dir(self):
        proc = self.runIn(
            '.', '-v', '-s', support_file('scenario/tests_in_package'), 'pkg1')
        self.assertTestRunOutputMatches(proc, stderr='Ran 25 tests')
        self.assertEqual(proc.poll(), 1)

    def test_function_name(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.test_func')
        self.assertTestRunOutputMatches(
            proc, stderr='test_func')
        self.assertTestRunOutputMatches(
            proc, stderr='Ran 1 test')
        self.assertTestRunOutputMatches(
            proc, stderr='OK')
        self.assertEqual(proc.poll(), 0)

    def test_generator_function_name(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.test_gen')
        self.assertTestRunOutputMatches(proc, stderr='test_gen')
        self.assertTestRunOutputMatches(proc, stderr='Ran 5 tests')
        self.assertEqual(proc.poll(), 0)

    def test_generator_function_index(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.test_gen:3')
        self.assertTestRunOutputMatches(proc, stderr='test_gen')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertEqual(proc.poll(), 0)

    def test_generator_function_index_1_based(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.test_gen:1')

        self.assertTestRunOutputMatches(proc, stderr='test_gen')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertTestRunOutputMatches(proc, stderr='OK')
        self.assertEqual(proc.poll(), 0)

    def test_testcase_name(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.SomeTests')
        self.assertTestRunOutputMatches(proc, stderr='SomeTests')
        self.assertTestRunOutputMatches(proc, stderr='Ran 8 tests')
        self.assertEqual(proc.poll(), 1)

    def test_testcase_method(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.SomeTests.test_ok')
        self.assertTestRunOutputMatches(proc, stderr='SomeTests')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertTestRunOutputMatches(proc, stderr='OK')
        self.assertEqual(proc.poll(), 0)

    def test_generator_method(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.SomeTests.test_gen_method')
        self.assertTestRunOutputMatches(proc, stderr='test_gen_method')
        self.assertTestRunOutputMatches(proc, stderr='Ran 2 tests')
        self.assertEqual(proc.poll(), 1)

    def test_generator_method_index(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.SomeTests.test_gen_method:1')
        self.assertTestRunOutputMatches(proc, stderr='test_gen_method')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertTestRunOutputMatches(proc, stderr='OK')
        self.assertEqual(proc.poll(), 0)

    def test_parameterized_method(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.SomeTests.test_params_method')
        self.assertTestRunOutputMatches(proc, stderr='test_params_method')
        self.assertTestRunOutputMatches(proc, stderr='Ran 2 tests')
        self.assertEqual(proc.poll(), 1)

    def test_parameterized_method_index(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.SomeTests.test_params_method:1')
        self.assertTestRunOutputMatches(proc, stderr='test_params_method')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertTestRunOutputMatches(proc, stderr='OK')
        self.assertEqual(proc.poll(), 0)

    def test_parameterized_func(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.test_params_func')
        self.assertTestRunOutputMatches(proc, stderr='test_params_func')
        self.assertTestRunOutputMatches(proc, stderr='Ran 2 tests')
        self.assertEqual(proc.poll(), 1)

    def test_parameterized_func_index(self):
        proc = self.runIn(
            'scenario/tests_in_package',
            '-v',
            'pkg1.test.test_things.test_params_func:1')
        self.assertTestRunOutputMatches(proc, stderr='test_params_func')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertTestRunOutputMatches(proc, stderr='OK')
        self.assertEqual(proc.poll(), 0)


class TestLoadTestsOutsideOfPackage(FunctionalTestCase):

    def test_module_name(self):
        proc = self.runIn(
            'scenario/package_in_lib',
            '-v',
            'tests')
        self.assertTestRunOutputMatches(proc, stderr='Ran 3 tests')
        self.assertEqual(proc.poll(), 1)

    def test_function_name(self):
        proc = self.runIn(
            'scenario/package_in_lib',
            '-v',
            'tests.test')
        self.assertTestRunOutputMatches(proc, stderr='test')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertTestRunOutputMatches(proc, stderr='OK')
        self.assertEqual(proc.poll(), 0)

    def test_module_name_with_start_dir(self):
        proc = self.runIn(
            '.', '-v', '-s', support_file('scenario/package_in_lib'), 'tests')
        self.assertTestRunOutputMatches(proc, stderr='Ran 3 tests')
        self.assertEqual(proc.poll(), 1)


class TestLoadingErrors(FunctionalTestCase):

    def test_import_error_module(self):
        proc = self.runIn(
            'scenario/module_import_err',
            '-v',
            'test_import_err')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertEqual(proc.poll(), 1)

    def test_import_error_func(self):
        proc = self.runIn(
            'scenario/module_import_err',
            '-v',
            'test_import_err.test')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertEqual(proc.poll(), 1)

    def test_import_error_testcase(self):
        proc = self.runIn(
            'scenario/module_import_err',
            '-v',
            'test_import_err.Test')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertEqual(proc.poll(), 1)

    def test_import_error_testcase_method(self):
        proc = self.runIn(
            'scenario/module_import_err',
            '-v',
            'test_import_err.Test.test')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertEqual(proc.poll(), 1)


class TestTestClassLoading(FunctionalTestCase):

    def test_load_testclass_by_name(self):
        proc = self.runIn(
            'scenario/test_classes',
            '-v',
            'test_classes.Test')
        self.assertTestRunOutputMatches(proc, stderr='Ran 8 tests')
        self.assertEqual(proc.poll(), 0)

    def test_load_testclass_method_by_name(self):
        proc = self.runIn(
            'scenario/test_classes',
            '-v',
            'test_classes.Test.test')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertEqual(proc.poll(), 0)

    def test_load_testclass_generator_method_by_name(self):
        proc = self.runIn(
            'scenario/test_classes',
            '-v',
            'test_classes.Test.test_gen')
        self.assertTestRunOutputMatches(proc, stderr='Ran 5 tests')
        self.assertEqual(proc.poll(), 0)

    def test_load_testclass_params_method_by_name(self):
        proc = self.runIn(
            'scenario/test_classes',
            '-v',
            'test_classes.Test.test_params')
        self.assertTestRunOutputMatches(proc, stderr='Ran 2 tests')
        self.assertEqual(proc.poll(), 0)

    def test_class_level_fixtures_supported(self):
        proc = self.runIn(
            'scenario/test_classes',
            '-v',
            'test_fixtures')
        self.assertTestRunOutputMatches(proc, stderr='Ran 5 tests')
        self.assertEqual(proc.poll(), 0)

    def test_error_in_test_class(self):
        proc = self.runIn(
            'scenario/test_class_fail',
            '-v',
            'test_class_fail')
        self.assertTestRunOutputMatches(proc, stderr='nose2.loader.LoadTestsFailure')
        self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
        self.assertTestRunOutputMatches(proc, stderr='FAILED')
        self.assertEqual(proc.poll(), 1)
    
    def test_expected_failures(self):
        proc = self.runIn(
            'scenario/expected_failures',
            '-v',
            'expected_failures')
        self.assertTestRunOutputMatches(proc, stderr=r'FAILED \(failures=1, expected failures=1, unexpected successes=1\)')