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