Show More
@@ -21,34 +21,53 b' import inspect' | |||||
21 | import os |
|
21 | import os | |
22 | import re |
|
22 | import re | |
23 | import runpy |
|
23 | import runpy | |
|
24 | import subprocess | |||
24 | import sys |
|
25 | import sys | |
25 | import tempfile |
|
26 | import tempfile | |
26 | import traceback |
|
27 | import traceback | |
27 | import types |
|
28 | import types | |
28 | import subprocess |
|
|||
29 | import warnings |
|
29 | import warnings | |
|
30 | from ast import stmt | |||
30 | from io import open as io_open |
|
31 | from io import open as io_open | |
31 |
|
32 | from logging import error | ||
32 | from pathlib import Path |
|
33 | from pathlib import Path | |
33 | from pickleshare import PickleShareDB |
|
34 | from typing import Callable | |
|
35 | from typing import List as ListType | |||
|
36 | from typing import Optional, Tuple | |||
|
37 | from warnings import warn | |||
34 |
|
38 | |||
|
39 | from pickleshare import PickleShareDB | |||
|
40 | from tempfile import TemporaryDirectory | |||
|
41 | from traitlets import ( | |||
|
42 | Any, | |||
|
43 | Bool, | |||
|
44 | CaselessStrEnum, | |||
|
45 | Dict, | |||
|
46 | Enum, | |||
|
47 | Instance, | |||
|
48 | Integer, | |||
|
49 | List, | |||
|
50 | Type, | |||
|
51 | Unicode, | |||
|
52 | default, | |||
|
53 | observe, | |||
|
54 | validate, | |||
|
55 | ) | |||
35 | from traitlets.config.configurable import SingletonConfigurable |
|
56 | from traitlets.config.configurable import SingletonConfigurable | |
36 | from traitlets.utils.importstring import import_item |
|
57 | from traitlets.utils.importstring import import_item | |
37 | from IPython.core import oinspect |
|
58 | ||
38 | from IPython.core import magic |
|
59 | import IPython.core.hooks | |
39 | from IPython.core import page |
|
60 | from IPython.core import magic, oinspect, page, prefilter, ultratb | |
40 | from IPython.core import prefilter |
|
|||
41 | from IPython.core import ultratb |
|
|||
42 | from IPython.core.alias import Alias, AliasManager |
|
61 | from IPython.core.alias import Alias, AliasManager | |
43 | from IPython.core.autocall import ExitAutocall |
|
62 | from IPython.core.autocall import ExitAutocall | |
44 | from IPython.core.builtin_trap import BuiltinTrap |
|
63 | from IPython.core.builtin_trap import BuiltinTrap | |
45 | from IPython.core.events import EventManager, available_events |
|
|||
46 | from IPython.core.compilerop import CachingCompiler, check_linecache_ipython |
|
64 | from IPython.core.compilerop import CachingCompiler, check_linecache_ipython | |
47 | from IPython.core.debugger import InterruptiblePdb |
|
65 | from IPython.core.debugger import InterruptiblePdb | |
48 | from IPython.core.display_trap import DisplayTrap |
|
66 | from IPython.core.display_trap import DisplayTrap | |
49 | from IPython.core.displayhook import DisplayHook |
|
67 | from IPython.core.displayhook import DisplayHook | |
50 | from IPython.core.displaypub import DisplayPublisher |
|
68 | from IPython.core.displaypub import DisplayPublisher | |
51 | from IPython.core.error import InputRejected, UsageError |
|
69 | from IPython.core.error import InputRejected, UsageError | |
|
70 | from IPython.core.events import EventManager, available_events | |||
52 | from IPython.core.extensions import ExtensionManager |
|
71 | from IPython.core.extensions import ExtensionManager | |
53 | from IPython.core.formatters import DisplayFormatter |
|
72 | from IPython.core.formatters import DisplayFormatter | |
54 | from IPython.core.history import HistoryManager |
|
73 | from IPython.core.history import HistoryManager | |
@@ -60,31 +79,17 b' from IPython.core.prefilter import PrefilterManager' | |||||
60 | from IPython.core.profiledir import ProfileDir |
|
79 | from IPython.core.profiledir import ProfileDir | |
61 | from IPython.core.usage import default_banner |
|
80 | from IPython.core.usage import default_banner | |
62 | from IPython.display import display |
|
81 | from IPython.display import display | |
|
82 | from IPython.paths import get_ipython_dir | |||
63 | from IPython.testing.skipdoctest import skip_doctest |
|
83 | from IPython.testing.skipdoctest import skip_doctest | |
64 | from IPython.utils import PyColorize |
|
84 | from IPython.utils import PyColorize, io, openpy, py3compat | |
65 | from IPython.utils import io |
|
|||
66 | from IPython.utils import py3compat |
|
|||
67 | from IPython.utils import openpy |
|
|||
68 | from IPython.utils.decorators import undoc |
|
85 | from IPython.utils.decorators import undoc | |
69 | from IPython.utils.io import ask_yes_no |
|
86 | from IPython.utils.io import ask_yes_no | |
70 | from IPython.utils.ipstruct import Struct |
|
87 | from IPython.utils.ipstruct import Struct | |
71 | from IPython.paths import get_ipython_dir |
|
88 | from IPython.utils.path import ensure_dir_exists, get_home_dir, get_py_filename | |
72 | from IPython.utils.path import get_home_dir, get_py_filename, ensure_dir_exists |
|
89 | from IPython.utils.process import getoutput, system | |
73 | from IPython.utils.process import system, getoutput |
|
|||
74 | from IPython.utils.strdispatch import StrDispatch |
|
90 | from IPython.utils.strdispatch import StrDispatch | |
75 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
91 | from IPython.utils.syspathcontext import prepended_to_syspath | |
76 |
from IPython.utils.text import |
|
92 | from IPython.utils.text import DollarFormatter, LSString, SList, format_screen | |
77 | from IPython.utils.tempdir import TemporaryDirectory |
|
|||
78 | from traitlets import ( |
|
|||
79 | Integer, Bool, CaselessStrEnum, Enum, List, Dict, Unicode, Instance, Type, |
|
|||
80 | observe, default, validate, Any |
|
|||
81 | ) |
|
|||
82 | from warnings import warn |
|
|||
83 | from logging import error |
|
|||
84 | import IPython.core.hooks |
|
|||
85 |
|
||||
86 | from typing import List as ListType, Tuple, Optional, Callable |
|
|||
87 | from ast import stmt |
|
|||
88 |
|
93 | |||
89 | sphinxify: Optional[Callable] |
|
94 | sphinxify: Optional[Callable] | |
90 |
|
95 | |||
@@ -123,8 +128,13 b' _single_targets_nodes = (ast.AugAssign, ast.AnnAssign)' | |||||
123 |
|
128 | |||
124 | # we still need to run things using the asyncio eventloop, but there is no |
|
129 | # we still need to run things using the asyncio eventloop, but there is no | |
125 | # async integration |
|
130 | # async integration | |
126 | from .async_helpers import _asyncio_runner, _pseudo_sync_runner |
|
131 | from .async_helpers import ( | |
127 | from .async_helpers import _curio_runner, _trio_runner, _should_be_async |
|
132 | _asyncio_runner, | |
|
133 | _curio_runner, | |||
|
134 | _pseudo_sync_runner, | |||
|
135 | _should_be_async, | |||
|
136 | _trio_runner, | |||
|
137 | ) | |||
128 |
|
138 | |||
129 | #----------------------------------------------------------------------------- |
|
139 | #----------------------------------------------------------------------------- | |
130 | # Globals |
|
140 | # Globals | |
@@ -2038,8 +2048,12 b' class InteractiveShell(SingletonConfigurable):' | |||||
2038 | (typically over the network by remote frontends). |
|
2048 | (typically over the network by remote frontends). | |
2039 | """ |
|
2049 | """ | |
2040 | from IPython.core.completer import IPCompleter |
|
2050 | from IPython.core.completer import IPCompleter | |
2041 |
from IPython.core.completerlib import ( |
|
2051 | from IPython.core.completerlib import ( | |
2042 | magic_run_completer, cd_completer, reset_completer) |
|
2052 | cd_completer, | |
|
2053 | magic_run_completer, | |||
|
2054 | module_completer, | |||
|
2055 | reset_completer, | |||
|
2056 | ) | |||
2043 |
|
2057 | |||
2044 | self.Completer = IPCompleter(shell=self, |
|
2058 | self.Completer = IPCompleter(shell=self, | |
2045 | namespace=self.user_ns, |
|
2059 | namespace=self.user_ns, | |
@@ -3398,8 +3412,9 b' class InteractiveShell(SingletonConfigurable):' | |||||
3398 | make sense in all contexts, for example a terminal ipython can't |
|
3412 | make sense in all contexts, for example a terminal ipython can't | |
3399 | display figures inline. |
|
3413 | display figures inline. | |
3400 | """ |
|
3414 | """ | |
3401 | from IPython.core import pylabtools as pt |
|
|||
3402 | from matplotlib_inline.backend_inline import configure_inline_support |
|
3415 | from matplotlib_inline.backend_inline import configure_inline_support | |
|
3416 | ||||
|
3417 | from IPython.core import pylabtools as pt | |||
3403 | gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select) |
|
3418 | gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select) | |
3404 |
|
3419 | |||
3405 | if gui != 'inline': |
|
3420 | if gui != 'inline': |
@@ -4,11 +4,11 b'' | |||||
4 | import os |
|
4 | import os | |
5 | import tempfile |
|
5 | import tempfile | |
6 |
|
6 | |||
|
7 | from tempfile import TemporaryDirectory | |||
7 | from traitlets import Unicode |
|
8 | from traitlets import Unicode | |
8 |
|
9 | |||
9 | from IPython.core.application import BaseIPythonApplication |
|
10 | from IPython.core.application import BaseIPythonApplication | |
10 | from IPython.testing import decorators as dec |
|
11 | from IPython.testing import decorators as dec | |
11 | from IPython.utils.tempdir import TemporaryDirectory |
|
|||
12 |
|
12 | |||
13 |
|
13 | |||
14 | @dec.onlyif_unicode_paths |
|
14 | @dec.onlyif_unicode_paths |
@@ -14,8 +14,9 b' import tempfile' | |||||
14 | import unittest |
|
14 | import unittest | |
15 | from os.path import join |
|
15 | from os.path import join | |
16 |
|
16 | |||
|
17 | from tempfile import TemporaryDirectory | |||
|
18 | ||||
17 | from IPython.core.completerlib import magic_run_completer, module_completion, try_import |
|
19 | from IPython.core.completerlib import magic_run_completer, module_completion, try_import | |
18 | from IPython.utils.tempdir import TemporaryDirectory |
|
|||
19 | from IPython.testing.decorators import onlyif_unicode_paths |
|
20 | from IPython.testing.decorators import onlyif_unicode_paths | |
20 |
|
21 | |||
21 |
|
22 |
@@ -1,8 +1,9 b'' | |||||
1 | import os.path |
|
1 | import os.path | |
2 |
|
2 | |||
|
3 | from tempfile import TemporaryDirectory | |||
|
4 | ||||
3 | import IPython.testing.tools as tt |
|
5 | import IPython.testing.tools as tt | |
4 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
6 | from IPython.utils.syspathcontext import prepended_to_syspath | |
5 | from IPython.utils.tempdir import TemporaryDirectory |
|
|||
6 |
|
7 | |||
7 | ext1_content = """ |
|
8 | ext1_content = """ | |
8 | def load_ipython_extension(ip): |
|
9 | def load_ipython_extension(ip): |
@@ -7,17 +7,19 b'' | |||||
7 |
|
7 | |||
8 | # stdlib |
|
8 | # stdlib | |
9 | import io |
|
9 | import io | |
10 | from pathlib import Path |
|
10 | import sqlite3 | |
11 | import sys |
|
11 | import sys | |
12 | import tempfile |
|
12 | import tempfile | |
13 | from datetime import datetime |
|
13 | from datetime import datetime | |
14 | import sqlite3 |
|
14 | from pathlib import Path | |
15 |
|
15 | |||
|
16 | from tempfile import TemporaryDirectory | |||
16 | # our own packages |
|
17 | # our own packages | |
17 | from traitlets.config.loader import Config |
|
18 | from traitlets.config.loader import Config | |
18 | from IPython.utils.tempdir import TemporaryDirectory |
|
19 | ||
19 | from IPython.core.history import HistoryManager, extract_hist_ranges |
|
20 | from IPython.core.history import HistoryManager, extract_hist_ranges | |
20 |
|
21 | |||
|
22 | ||||
21 | def test_proper_default_encoding(): |
|
23 | def test_proper_default_encoding(): | |
22 | assert sys.getdefaultencoding() == "utf-8" |
|
24 | assert sys.getdefaultencoding() == "utf-8" | |
23 |
|
25 |
@@ -2,9 +2,10 b'' | |||||
2 | """Test IPython.core.logger""" |
|
2 | """Test IPython.core.logger""" | |
3 |
|
3 | |||
4 | import os.path |
|
4 | import os.path | |
|
5 | ||||
5 | import pytest |
|
6 | import pytest | |
|
7 | from tempfile import TemporaryDirectory | |||
6 |
|
8 | |||
7 | from IPython.utils.tempdir import TemporaryDirectory |
|
|||
8 |
|
9 | |||
9 | def test_logstart_inaccessible_file(): |
|
10 | def test_logstart_inaccessible_file(): | |
10 | with pytest.raises(IOError): |
|
11 | with pytest.raises(IOError): |
@@ -6,11 +6,11 b' import tempfile' | |||||
6 | import warnings |
|
6 | import warnings | |
7 | from unittest.mock import patch |
|
7 | from unittest.mock import patch | |
8 |
|
8 | |||
9 | from testpath import modified_env, assert_isdir, assert_isfile |
|
9 | from tempfile import TemporaryDirectory | |
|
10 | from testpath import assert_isdir, assert_isfile, modified_env | |||
10 |
|
11 | |||
11 | from IPython import paths |
|
12 | from IPython import paths | |
12 | from IPython.testing.decorators import skip_win32 |
|
13 | from IPython.testing.decorators import skip_win32 | |
13 | from IPython.utils.tempdir import TemporaryDirectory |
|
|||
14 |
|
14 | |||
15 | TMP_TEST_DIR = os.path.realpath(tempfile.mkdtemp()) |
|
15 | TMP_TEST_DIR = os.path.realpath(tempfile.mkdtemp()) | |
16 | HOME_TEST_DIR = os.path.join(TMP_TEST_DIR, "home_test_dir") |
|
16 | HOME_TEST_DIR = os.path.join(TMP_TEST_DIR, "home_test_dir") |
@@ -23,17 +23,16 b' Authors' | |||||
23 | import shutil |
|
23 | import shutil | |
24 | import sys |
|
24 | import sys | |
25 | import tempfile |
|
25 | import tempfile | |
26 |
|
||||
27 | from pathlib import Path |
|
26 | from pathlib import Path | |
28 | from unittest import TestCase |
|
27 | from unittest import TestCase | |
29 |
|
28 | |||
30 | from IPython.core.profileapp import list_profiles_in, list_bundled_profiles |
|
29 | from tempfile import TemporaryDirectory | |
31 | from IPython.core.profiledir import ProfileDir |
|
|||
32 |
|
30 | |||
|
31 | from IPython.core.profileapp import list_bundled_profiles, list_profiles_in | |||
|
32 | from IPython.core.profiledir import ProfileDir | |||
33 | from IPython.testing import decorators as dec |
|
33 | from IPython.testing import decorators as dec | |
34 | from IPython.testing import tools as tt |
|
34 | from IPython.testing import tools as tt | |
35 | from IPython.utils.process import getoutput |
|
35 | from IPython.utils.process import getoutput | |
36 | from IPython.utils.tempdir import TemporaryDirectory |
|
|||
37 |
|
36 | |||
38 | #----------------------------------------------------------------------------- |
|
37 | #----------------------------------------------------------------------------- | |
39 | # Globals |
|
38 | # Globals |
@@ -19,21 +19,22 b' as otherwise it may influence later tests.' | |||||
19 | import functools |
|
19 | import functools | |
20 | import os |
|
20 | import os | |
21 | import platform |
|
21 | import platform | |
22 | from os.path import join as pjoin |
|
|||
23 | import random |
|
22 | import random | |
24 | import string |
|
23 | import string | |
25 | import sys |
|
24 | import sys | |
26 | import textwrap |
|
25 | import textwrap | |
27 | import unittest |
|
26 | import unittest | |
|
27 | from os.path import join as pjoin | |||
28 | from unittest.mock import patch |
|
28 | from unittest.mock import patch | |
29 |
|
29 | |||
30 | import pytest |
|
30 | import pytest | |
|
31 | from tempfile import TemporaryDirectory | |||
31 |
|
32 | |||
|
33 | from IPython.core import debugger | |||
32 | from IPython.testing import decorators as dec |
|
34 | from IPython.testing import decorators as dec | |
33 | from IPython.testing import tools as tt |
|
35 | from IPython.testing import tools as tt | |
34 | from IPython.utils.io import capture_output |
|
36 | from IPython.utils.io import capture_output | |
35 | from IPython.utils.tempdir import TemporaryDirectory |
|
37 | ||
36 | from IPython.core import debugger |
|
|||
37 |
|
38 | |||
38 | def doctest_refbug(): |
|
39 | def doctest_refbug(): | |
39 | """Very nasty problem with references held by multiple runs of a script. |
|
40 | """Very nasty problem with references held by multiple runs of a script. | |
@@ -411,6 +412,7 b' tclass.py: deleting object: C-third' | |||||
411 | """Test %run notebook.ipynb error""" |
|
412 | """Test %run notebook.ipynb error""" | |
412 | pytest.importorskip("nbformat") |
|
413 | pytest.importorskip("nbformat") | |
413 | from nbformat import v4, writes |
|
414 | from nbformat import v4, writes | |
|
415 | ||||
414 | # %run when a file name isn't provided |
|
416 | # %run when a file name isn't provided | |
415 | pytest.raises(Exception, _ip.magic, "run") |
|
417 | pytest.raises(Exception, _ip.magic, "run") | |
416 |
|
418 |
@@ -3,21 +3,20 b'' | |||||
3 | """ |
|
3 | """ | |
4 | import io |
|
4 | import io | |
5 | import logging |
|
5 | import logging | |
|
6 | import os.path | |||
6 | import platform |
|
7 | import platform | |
7 | import re |
|
8 | import re | |
8 | import sys |
|
9 | import sys | |
9 | import os.path |
|
|||
10 | from textwrap import dedent |
|
|||
11 | import traceback |
|
10 | import traceback | |
12 | import unittest |
|
11 | import unittest | |
|
12 | from textwrap import dedent | |||
13 |
|
13 | |||
14 | from IPython.core.ultratb import ColorTB, VerboseTB |
|
14 | from tempfile import TemporaryDirectory | |
15 |
|
||||
16 |
|
15 | |||
|
16 | from IPython.core.ultratb import ColorTB, VerboseTB | |||
17 | from IPython.testing import tools as tt |
|
17 | from IPython.testing import tools as tt | |
18 | from IPython.testing.decorators import onlyif_unicode_paths |
|
18 | from IPython.testing.decorators import onlyif_unicode_paths | |
19 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
19 | from IPython.utils.syspathcontext import prepended_to_syspath | |
20 | from IPython.utils.tempdir import TemporaryDirectory |
|
|||
21 |
|
20 | |||
22 | file_1 = """1 |
|
21 | file_1 = """1 | |
23 | 2 |
|
22 | 2 |
@@ -4,14 +4,15 b'' | |||||
4 | # Copyright (c) IPython Development Team. |
|
4 | # Copyright (c) IPython Development Team. | |
5 | # Distributed under the terms of the Modified BSD License. |
|
5 | # Distributed under the terms of the Modified BSD License. | |
6 |
|
6 | |||
7 | import pytest |
|
|||
8 | import types |
|
7 | import types | |
9 |
|
||||
10 | from pathlib import Path |
|
8 | from pathlib import Path | |
11 |
|
9 | |||
|
10 | import pytest | |||
|
11 | from tempfile import TemporaryDirectory | |||
|
12 | ||||
|
13 | from IPython.lib.deepreload import modules_reloading | |||
|
14 | from IPython.lib.deepreload import reload as dreload | |||
12 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
15 | from IPython.utils.syspathcontext import prepended_to_syspath | |
13 | from IPython.utils.tempdir import TemporaryDirectory |
|
|||
14 | from IPython.lib.deepreload import reload as dreload, modules_reloading |
|
|||
15 |
|
16 | |||
16 |
|
17 | |||
17 | def test_deepreload(): |
|
18 | def test_deepreload(): |
@@ -10,8 +10,7 b' from tempfile import TemporaryDirectory' | |||||
10 |
|
10 | |||
11 |
|
11 | |||
12 | class NamedFileInTemporaryDirectory(object): |
|
12 | class NamedFileInTemporaryDirectory(object): | |
13 |
|
13 | def __init__(self, filename, mode="w+b", bufsize=-1, add_to_syspath=False, **kwds): | ||
14 | def __init__(self, filename, mode='w+b', bufsize=-1, **kwds): |
|
|||
15 | """ |
|
14 | """ | |
16 | Open a file named `filename` in a temporary directory. |
|
15 | Open a file named `filename` in a temporary directory. | |
17 |
|
16 |
@@ -10,24 +10,23 b' import sys' | |||||
10 | import tempfile |
|
10 | import tempfile | |
11 | import unittest |
|
11 | import unittest | |
12 | from contextlib import contextmanager |
|
12 | from contextlib import contextmanager | |
13 | from unittest.mock import patch |
|
|||
14 | from os.path import join, abspath |
|
|||
15 | from importlib import reload |
|
13 | from importlib import reload | |
|
14 | from os.path import abspath, join | |||
|
15 | from unittest.mock import patch | |||
16 |
|
16 | |||
17 | import pytest |
|
17 | import pytest | |
|
18 | from tempfile import TemporaryDirectory | |||
18 |
|
19 | |||
19 | import IPython |
|
20 | import IPython | |
20 | from IPython import paths |
|
21 | from IPython import paths | |
21 | from IPython.testing import decorators as dec |
|
22 | from IPython.testing import decorators as dec | |
22 | from IPython.testing.decorators import ( |
|
23 | from IPython.testing.decorators import ( | |
|
24 | onlyif_unicode_paths, | |||
23 | skip_if_not_win32, |
|
25 | skip_if_not_win32, | |
24 | skip_win32, |
|
26 | skip_win32, | |
25 | onlyif_unicode_paths, |
|
|||
26 | ) |
|
27 | ) | |
27 | from IPython.testing.tools import make_tempfile |
|
28 | from IPython.testing.tools import make_tempfile | |
28 | from IPython.utils import path |
|
29 | from IPython.utils import path | |
29 | from IPython.utils.tempdir import TemporaryDirectory |
|
|||
30 |
|
||||
31 |
|
30 | |||
32 | # Platform-dependent imports |
|
31 | # Platform-dependent imports | |
33 | try: |
|
32 | try: | |
@@ -41,6 +40,7 b' except ImportError:' | |||||
41 | import winreg as wreg |
|
40 | import winreg as wreg | |
42 | except ImportError: |
|
41 | except ImportError: | |
43 | import _winreg as wreg |
|
42 | import _winreg as wreg | |
|
43 | ||||
44 | #Add entries that needs to be stubbed by the testing code |
|
44 | #Add entries that needs to be stubbed by the testing code | |
45 | (wreg.OpenKey, wreg.QueryValueEx,) = (None, None) |
|
45 | (wreg.OpenKey, wreg.QueryValueEx,) = (None, None) | |
46 |
|
46 |
General Comments 0
You need to be logged in to leave comments.
Login now