This file is indexed.

/usr/lib/python2.7/dist-packages/jupyter_core/tests/test_application.py is in python-jupyter-core 4.2.1-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
import os
import shutil
from tempfile import mkdtemp
from ipython_genutils import py3compat

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

import pytest
from traitlets import Integer

from jupyter_core.application import JupyterApp, NoStart

pjoin = os.path.join


def test_basic():
    app = JupyterApp()


def test_default_traits():
    app = JupyterApp()
    for trait_name in app.traits():
        value = getattr(app, trait_name)

class DummyApp(JupyterApp):
    name = "dummy-app"
    m = Integer(0, config=True)
    n = Integer(0, config=True)

_dummy_config = """
c.DummyApp.n = 10
"""

def test_custom_config():
    app = DummyApp()
    td = mkdtemp()
    fname = pjoin(td, 'config.py')
    with open(fname, 'w') as f:
        f.write(_dummy_config)
    app.initialize(['--config', fname])
    shutil.rmtree(td)
    assert app.config_file == fname
    assert app.n == 10

def test_cli_override():
    app = DummyApp()
    td = mkdtemp()
    fname = pjoin(td, 'config.py')
    with open(fname, 'w') as f:
        f.write(_dummy_config)
    app.initialize(['--config', fname, '--DummyApp.n=20'])
    shutil.rmtree(td)
    assert app.n == 20


def test_generate_config():
    td = mkdtemp()
    app = DummyApp(config_dir=td)
    app.initialize(['--generate-config'])
    assert app.generate_config
    
    with pytest.raises(NoStart):
        app.start()
    
    assert os.path.exists(os.path.join(td, 'dummy_app_config.py'))


def test_load_config():
    config_dir = mkdtemp()
    wd = mkdtemp()
    with open(pjoin(config_dir, 'dummy_app_config.py'), 'w') as f:
        f.write('c.DummyApp.m = 1\n')
        f.write('c.DummyApp.n = 1')
    with patch.object(py3compat, 'getcwd', lambda : wd):
        app = DummyApp(config_dir=config_dir)
        app.initialize([])

    assert app.n == 1, "Loaded config from config dir"
    
    with open(pjoin(wd, 'dummy_app_config.py'), 'w') as f:
        f.write('c.DummyApp.n = 2')

    with patch.object(py3compat, 'getcwd', lambda : wd):
        app = DummyApp(config_dir=config_dir)
        app.initialize([])

    assert app.m == 1, "Loaded config from config dir"
    assert app.n == 2, "Loaded config from CWD"
    
    shutil.rmtree(config_dir)
    shutil.rmtree(wd)