This file is indexed.

/usr/lib/python2.7/dist-packages/notebook/bundler/tests/test_bundlerextension.py is in python-notebook 5.2.2-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
"""Test the bundlerextension CLI."""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

import os
import shutil
import unittest

try:
    from unittest.mock import patch
except ImportError:
    from mock import patch # py2

from ipython_genutils.tempdir import TemporaryDirectory
from ipython_genutils import py3compat

from traitlets.config.manager import BaseJSONConfigManager
from traitlets.tests.utils import check_help_all_output

import notebook.nbextensions as nbextensions
from ..bundlerextensions import (_get_config_dir, enable_bundler_python, 
    disable_bundler_python)

def test_help_output():
    check_help_all_output('notebook.bundler.bundlerextensions')
    check_help_all_output('notebook.bundler.bundlerextensions', ['enable'])
    check_help_all_output('notebook.bundler.bundlerextensions', ['disable'])

class TestBundlerExtensionCLI(unittest.TestCase):
    """Tests the bundlerextension CLI against the example zip_bundler."""
    def setUp(self):
        """Build an isolated config environment."""
        td = TemporaryDirectory()
        
        self.test_dir = py3compat.cast_unicode(td.name)
        self.data_dir = os.path.join(self.test_dir, 'data')
        self.config_dir = os.path.join(self.test_dir, 'config')
        self.system_data_dir = os.path.join(self.test_dir, 'system_data')
        self.system_path = [self.system_data_dir]
        
        # Use temp directory, not real user or system config paths
        self.patch_env = patch.dict('os.environ', {
            'JUPYTER_CONFIG_DIR': self.config_dir,
            'JUPYTER_DATA_DIR': self.data_dir,
        })
        self.patch_env.start()
        self.patch_system_path = patch.object(nbextensions,
            'SYSTEM_JUPYTER_PATH', self.system_path)
        self.patch_system_path.start()
         
    def tearDown(self):
        """Remove the test config environment."""
        shutil.rmtree(self.test_dir, ignore_errors=True)
        self.patch_env.stop()
        self.patch_system_path.stop()
                
    def test_enable(self):
        """Should add the bundler to the notebook configuration."""
        enable_bundler_python('notebook.bundler.zip_bundler')
        
        config_dir = os.path.join(_get_config_dir(user=True), 'nbconfig')
        cm = BaseJSONConfigManager(config_dir=config_dir)
        bundlers = cm.get('notebook').get('bundlerextensions', {})
        self.assertEqual(len(bundlers), 1)
        self.assertIn('notebook_zip_download', bundlers)
    
    def test_disable(self):
        """Should remove the bundler from the notebook configuration."""
        self.test_enable()
        disable_bundler_python('notebook.bundler.zip_bundler')
        
        config_dir = os.path.join(_get_config_dir(user=True), 'nbconfig')
        cm = BaseJSONConfigManager(config_dir=config_dir)
        bundlers = cm.get('notebook').get('bundlerextensions', {})
        self.assertEqual(len(bundlers), 0)