File: test_utils_console.py

package info (click to toggle)
python-scrapy 2.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,308 kB
  • sloc: python: 55,321; xml: 199; makefile: 25; sh: 7
file content (41 lines) | stat: -rw-r--r-- 979 bytes parent folder | download
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
import pytest

from scrapy.utils.console import get_shell_embed_func

try:
    import bpython

    bpy = True
    del bpython
except ImportError:
    bpy = False
try:
    import IPython

    ipy = True
    del IPython
except ImportError:
    ipy = False


def test_get_shell_embed_func():
    shell = get_shell_embed_func(["invalid"])
    assert shell is None

    shell = get_shell_embed_func(["invalid", "python"])
    assert callable(shell)
    assert shell.__name__ == "_embed_standard_shell"


@pytest.mark.skipif(not bpy, reason="bpython not available in testenv")
def test_get_shell_embed_func_bpython():
    shell = get_shell_embed_func(["bpython"])
    assert callable(shell)
    assert shell.__name__ == "_embed_bpython_shell"


@pytest.mark.skipif(not ipy, reason="IPython not available in testenv")
def test_get_shell_embed_func_ipython():
    # default shell should be 'ipython'
    shell = get_shell_embed_func()
    assert shell.__name__ == "_embed_ipython_shell"