This file is indexed.

/usr/lib/python2.7/dist-packages/jupyter_console/tests/test_console.py is in python-jupyter-console 5.0.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
"""Tests for two-process terminal frontend"""

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

import os
import shutil
import sys
import tempfile
from subprocess import check_output

from nose import SkipTest

from traitlets.tests.utils import check_help_all_output
from ipython_genutils.testing import decorators as dec

@dec.skip_win32
def test_console_starts():
    """test that `jupyter console` starts a terminal"""
    p, pexpect, t = start_console()
    p.sendline('5')
    idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=t)
    idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
    stop_console(p, pexpect, t)

def test_help_output():
    """jupyter console --help-all works"""
    check_help_all_output('jupyter_console')

def test_display_text():
    "Ensure display protocol plain/text key is supported"
    # equivalent of:
    #
    #   x = %lsmagic
    #   from IPython.display import display; display(x);
    p, pexpect, t = start_console()
    p.sendline('x = %lsmagic')
    p.expect(r'In \[\d+\]', timeout=t)
    p.sendline('from IPython.display import display; display(x);')
    p.expect(r'Available line magics:', timeout=t)
    p.expect(r'In \[\d+\]', timeout=t)
    stop_console(p, pexpect, t)

def stop_console(p, pexpect, t):
    "Stop a running `jupyter console` running via pexpect"
    # send ctrl-D;ctrl-D to exit
    p.sendeof()
    p.sendeof()
    p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t)
    if p.isalive():
        p.terminate()


def start_console():
    "Start `jupyter console` using pexpect"
    import pexpect
    
    args = ['-m', 'jupyter_console', '--colors=NoColor']
    cmd = sys.executable
    env = os.environ.copy()
    env['JUPYTER_CONSOLE_TEST'] = '1'

    try:
        p = pexpect.spawn(cmd, args=args, env=env)
    except IOError:
        raise SkipTest("Couldn't find command %s" % cmd)
    
    # timeout after one minute
    t = 60
    idx = p.expect(r'In \[\d+\]', timeout=t)
    return p, pexpect, t


def test_generate_config():
    """jupyter console --generate-config works"""
    td = tempfile.mkdtemp()
    try:
        check_output([sys.executable, '-m', 'jupyter_console', '--generate-config'],
            env={'JUPYTER_CONFIG_DIR': td},
        )
        assert os.path.isfile(os.path.join(td, 'jupyter_console_config.py'))
    finally:
        shutil.rmtree(td)