This file is indexed.

/usr/share/pyshared/nipy/testing/nosetester.py is in python-nipy 0.3.0-1ubuntu2.

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
""" Nipy nosetester

Sets doctests to run by default

Use our own doctest plugin (based on that of numpy)
"""
from ..fixes.numpy.testing.nosetester import NoseTester, import_nose

def fpw_opt_str():
    """ Return first-package-wins option string for this version of nose

    Versions of nose prior to 1.1.0 needed ``=True`` for ``first-package-wins``,
    versions after won't accept it.

    changeset:   816:c344a4552d76
    http://code.google.com/p/python-nose/issues/detail?id=293

    Returns
    -------
    fpw_str : str
        Either '--first-package-wins' or '--first-package-wins=True' depending
        on the nose version we are running.
    """
    # protect nose import to provide comprehensible error if missing
    nose = import_nose()
    config = nose.config.Config()
    fpw_str = '--first-package-wins'
    opt_parser = config.getParser('')
    opt_def = opt_parser.get_option('--first-package-wins')
    if opt_def is None:
        raise RuntimeError('Nose does not accept "first-package-wins"'
                           ' - is this an old nose version?')
    if opt_def.takes_value(): # the =True variant
        fpw_str += '=True'
    return fpw_str


def prepare_imports():
    """ Prepare any imports for testing run

    At the moment, we prepare matplotlib by trying to make it use a backend that
    does not need a display
    """
    try:
        import matplotlib as mpl
    except ImportError:
        pass
    else:
        mpl.use('svg')


class NipyNoseTester(NoseTester):
    """ Numpy-like testing class

    * Removes some numpy-specific excludes
    * Disables numpy's fierce clearout of module import context for doctests
    * Run doctests by default

    """
    excludes = []

    def _get_custom_doctester(self):
        """ Use our our own doctester """
        import_nose()
        from .doctester import NipyDoctest
        return NipyDoctest()

    def test(self, label='fast', verbose=1, extra_argv=None, doctests=True,
             coverage=False):
        """
        Run tests for module using nose.

        As for numpy tester, except enable tests by default.

        Parameters
        ----------
        label : {'fast', 'full', '', attribute identifier}, optional
            Identifies the tests to run. This can be a string to pass to
            directly the nosetests executable with the '-A' option (an attribute
            identifier), or one of several special values.  Special values are:

            * 'fast' - the default - which corresponds to the ``nosetests -A``
              option of 'not slow'.
            * 'full' - fast (as above) and slow tests as in the
              'no -A' option to nosetests - this is the same as ''.
            * None or '' - run all tests.

        verbose : int, optional
            Verbosity value for test outputs, in the range 1-10. Default is 1.
        extra_argv : list, optional
            List with any extra arguments to pass to nosetests.
        doctests : bool, optional
            If True, run doctests in module. Default is True.
        coverage : bool, optional
            If True, report coverage of nipy code. Default is False.
            (This requires the `coverage module:
             <http://nedbatchelder.com/code/modules/coverage.html>`_).

        Returns
        -------
        result : object
            Returns the result of running the tests as a
            ``nose.result.TextTestResult`` object.

        Notes
        -----
        Each nipy module should expose `test` in its namespace to run all tests
        for it.  For example, to run all tests for nipy.algorithms:

        >>> import nipy.algorithms
        >>> nipy.algorithms.test() #doctest: +SKIP
        """
        prepare_imports()
        if extra_argv is None:
            extra_argv = []
        extra_argv.append(fpw_opt_str())
        return super(NipyNoseTester, self).test(label, verbose, extra_argv,
                                                doctests, coverage)