This file is indexed.

/usr/lib/python2.7/dist-packages/nose2/tests/unit/test_outcomes_plugin.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
from nose2.plugins import outcomes
from nose2 import events, result, session
from nose2.tests._common import TestCase


class TestOutComesPlugin(TestCase):
    tags = ['unit']

    def setUp(self):
        self.session = session.Session()
        self.result = result.PluggableTestResult(self.session)
        self.plugin = outcomes.Outcomes(session=self.session)
        self.plugin.register()

        class Test(TestCase):

            def test_e1(self):
                raise KeyError("k")

            def test_e2(self):
                raise TypeError("x")

            def test_e3(self):
                raise IOError("o")

        self.case = Test

        class Watcher(events.Plugin):

            def __init__(self):
                self.outcomes = {}

            def testOutcome(self, event):
                self.outcomes.setdefault(event.outcome, []).append(event)
        self.watcher = Watcher(session=self.session)
        self.watcher.register()

    def test_labels_upper(self):
        self.assertEqual(self.plugin.labels('xxx'), ('X', 'XXX'))

    def test_can_do_nothing_when_not_configured(self):
        test = self.case('test_e1')
        test(self.result)
        assert self.watcher.outcomes['error']
        assert not 'failed' in self.watcher.outcomes

    def test_can_treat_as_fail(self):
        self.plugin.treatAsFail.add('KeyError')
        test = self.case('test_e1')
        test(self.result)
        assert self.watcher.outcomes['failed']
        assert not 'error' in self.watcher.outcomes

    def test_can_treat_as_skip(self):
        self.plugin.treatAsSkip.add('KeyError')
        test = self.case('test_e1')
        test(self.result)
        assert self.watcher.outcomes['skipped']
        assert not 'error' in self.watcher.outcomes

    def test_can_handle_multiple_events_cleanly(self):
        self.plugin.treatAsSkip.add('KeyError')
        self.plugin.treatAsFail.add('TypeError')
        test = self.case('test_e1')
        test(self.result)
        test = self.case('test_e2')
        test(self.result)
        test = self.case('test_e3')
        test(self.result)
        self.assertEqual(len(self.watcher.outcomes['skipped']), 1)
        self.assertEqual(len(self.watcher.outcomes['error']), 1)
        self.assertEqual(len(self.watcher.outcomes['failed']), 1)