Repository: ipython/ipython

Issue:
Add narrative docs and example for #10500 custom keyboard function for enter
See #10500 even if unstable/dev only it might be good to document.

Discussion:
Carreau: Wow, that's not what I was meaning to do, but that's ok too. 

Patch:
diff --git a/IPython/core/completer.py b/IPython/core/completer.py
index fbcf45af7..06a1348b3 100644
--- a/IPython/core/completer.py
+++ b/IPython/core/completer.py
@@ -136,7 +136,6 @@
 from IPython.core.error import TryNext
 from IPython.core.inputsplitter import ESC_MAGIC
 from IPython.core.latex_symbols import latex_symbols, reverse_latex_symbol
-from IPython.core.oinspect import InspectColors
 from IPython.utils import generics
 from IPython.utils.dir2 import dir2, get_real_method
 from IPython.utils.process import arg_split
@@ -1050,14 +1049,11 @@ def __init__(self, shell=None, namespace=None, global_namespace=None,
         self.matchers = [
                          self.python_matches,
                          self.file_matches,
+                         self.magic_config_matches,
                          self.magic_matches,
                          self.python_func_kw_matches,
                          self.dict_key_matches,
                          ]
-        self.magic_arg_matchers = [
-            self.magic_config_matches,
-            self.magic_color_matches,
-        ]
 
         # This is set externally by InteractiveShell
         self.custom_completers = None
@@ -1185,11 +1181,13 @@ def magic_matches(self, text):
 
         return comp
 
-    def magic_config_matches(self, text:str) -> List[str]:
+    def magic_config_matches(self, text):
         """ Match class names and attributes for %config magic """
-        texts = text.strip().split()
+        # use line buffer instead of text (which is a word)
+        texts = self.line_buffer.strip().split()
 
-        if len(texts) > 0 and (texts[0] == 'config' or texts[0] == '%config'):
+        if len(texts) > 0 and \
+            ('config'.startswith(texts[0]) or '%config'.startswith(texts[0])):
             # get all configuration classes
             classes = sorted(set([ c for c in self.shell.configurables
                                    if c.__class__.class_traits(config=True)
@@ -1220,16 +1218,6 @@ def magic_config_matches(self, text:str) -> List[str]:
                          if attr.startswith(texts[1]) ]
         return []
 
-    def magic_color_matches(self, text:str) -> List[str] :
-        """ Match color schemes for %colors magic"""
-        texts = text.strip().split()
-
-        if len(texts) > 0 and (texts[0] == 'colors' or texts[0] == '%colors'):
-            prefix = texts[1] if len(texts) > 1 else ''
-            return [ color for color in InspectColors.keys()
-                     if color.startswith(prefix) ]
-        return []
-
     def _jedi_matches(self, cursor_column:int, cursor_line:int, text:str):
         """
 
@@ -1890,14 +1878,6 @@ def _complete(self, *, cursor_line, cursor_pos, line_buffer=None, text=None,
         self.line_buffer = line_buffer
         self.text_until_cursor = self.line_buffer[:cursor_pos]
 
-        # Do magic arg matches
-        for matcher in self.magic_arg_matchers:
-            matches = [(m, matcher.__qualname__) for m in matcher(line_buffer)]
-            if matches:
-                matches2 = [m[0] for m in matches]
-                origins = [m[1] for m in matches]
-                return text, matches2, origins, ()
-
         # Start with a clean slate of completions
         matches = []
         custom_res = self.dispatch_custom_completer(text)
diff --git a/IPython/core/display.py b/IPython/core/display.py
index 96015dedc..e1875e122 100644
--- a/IPython/core/display.py
+++ b/IPython/core/display.py
@@ -145,9 +145,6 @@ def display(*objs, include=None, exclude=None, metadata=None, transient=None, di
     By default all representations will be computed and sent to the frontends.
     Frontends can decide which representation is used and how.
 
-    In terminal IPython this will be similar to using :func:`print`, for use in richer
-    frontends see Jupyter notebook examples with rich display logic.
-
     Parameters
     ----------
     objs : tuple of objects
@@ -155,11 +152,11 @@ def display(*objs, include=None, exclude=None, metadata=None, transient=None, di
     raw : bool, optional
         Are the objects to be displayed already mimetype-keyed dicts of raw display data,
         or Python objects that need to be formatted before display? [default: False]
-    include : list, tuple or set, optional
+    include : list or tuple, optional
         A list of format type strings (MIME types) to include in the
         format data dict. If this is set *only* the format types included
         in this list will be computed.
-    exclude : list, tuple or set, optional
+    exclude : list or tuple, optional
         A list of format type strings (MIME types) to exclude in the format
         data dict. If this is set all format types will be computed,
         except for those included in this argument.
@@ -170,119 +167,25 @@ def display(*objs, include=None, exclude=None, metadata=None, transient=None, di
     transient : dict, optional
         A dictionary of transient data to associate with the output.
         Data in this dict should not be persisted to files (e.g. notebooks).
-    display_id : str, bool optional
+    display_id : str, optional
         Set an id for the display.
         This id can be used for updating this display area later via update_display.
-        If given as `True`, generate a new `display_id`
+        If given as True, generate a new display_id
     kwargs: additional keyword-args, optional
         Additional keyword-arguments are passed through to the display publisher.
-
+    
     Returns
     -------
-
+    
     handle: DisplayHandle
-        Returns a handle on updatable displays for use with :func:`update_display`,
-        if `display_id` is given. Returns :any:`None` if no `display_id` is given
-        (default).
-
-    Examples
-    --------
-
-    >>> class Json(object):
-    ...     def __init__(self, json):
-    ...         self.json = json
-    ...     def _repr_pretty_(self, pp, cycle):
-    ...         import json
-    ...         pp.text(json.dumps(self.json, indent=2))
-    ...     def __repr__(self):
-    ...         return str(self.json)
-    ...
-
-    >>> d = Json({1:2, 3: {4:5}})
-
-    >>> print(d)
-    {1: 2, 3: {4: 5}}
-
-    >>> display(d)
-    {
-      "1": 2,
-      "3": {
-        "4": 5
-      }
-    }
-
-    >>> def int_formatter(integer, pp, cycle):
-    ...     pp.text('I'*integer)
-
-    >>> plain = get_ipython().display_formatter.formatters['text/plain']
-    >>> plain.for_type(int, int_formatter)
-    <function _repr_pprint at 0x...>
-    >>> display(7-5)
-    II
-
-    >>> del plain.type_printers[int]
-    >>> display(7-5)
-    2
-
-    See Also
-    --------
-
-    :func:`update_display`
-
-    Notes
-    -----
-
-    In Python, objects can declare their textual representation using the
-    `__repr__` method. IPython expands on this idea and allows objects to declare
-    other, rich representations including:
-
-      - HTML
-      - JSON
-      - PNG
-      - JPEG
-      - SVG
-      - LaTeX
-
-    A single object can declare some or all of these representations; all are
-    handled by IPython's display system.
-
-    The main idea of the first approach is that you have to implement special
-    display methods when you define your class, one for each representation you
-    want to use. Here is a list of the names of the special methods and the
-    values they must return:
-
-      - `_repr_html_`: return raw HTML as a string
-      - `_repr_json_`: return a JSONable dict
-      - `_repr_jpeg_`: return raw JPEG data
-      - `_repr_png_`: return raw PNG data
-      - `_repr_svg_`: return raw SVG data as a string
-      - `_repr_latex_`: return LaTeX commands in a string surrounded by "$".
-      - `_repr_mimebundle_`: return a full mimebundle containing the mapping
-      from all mimetypes to data
-
-    When you are directly writing your own classes, you can adapt them for
-    display in IPython by following the above approach. But in practice, you
-    often need to work with existing classes that you can't easily modify.
-
-    You can refer to the documentation on IPython display formatters in order to
-    register custom formatters for already existing types.
-
-    .. versionadded:: 5.4 display available without import
-    .. versionadded:: 6.1 display available without import
-
-    Since IPython 5.4 and 6.1 :func:`display` is automatically made available to
-    the user without import. If you are using display in a document that might
-    be used in a pure python context or with older version of IPython, use the
-    following import at the top of your file::
-
-        from IPython.display import display
-
+        Returns a handle on updatable displays, if display_id is given.
+        Returns None if no display_id is given (default).
     """
     raw = kwargs.pop('raw', False)
     if transient is None:
         transient = {}
     if display_id:
-        if display_id is True:
+        if display_id == True:
             display_id = _new_id()
         transient['display_id'] = display_id
     if kwargs.get('update') and 'display_id' not in transient:
@@ -322,11 +225,6 @@ def update_display(obj, *, display_id, **kwargs):
         The object with which to update the display
     display_id: keyword-only
         The id of the display to update
-
-    See Also
-    --------
-
-    :func:`display`
     """
     kwargs['update'] = True
     display(obj, display_id=display_id, **kwargs)
@@ -335,16 +233,10 @@ def update_display(obj, *, display_id, **kwargs):
 class DisplayHandle(object):
     """A handle on an updatable display
 
-    Call `.update(obj)` to display a new object.
+    Call .update(obj) to display a new object.
 
-    Call `.display(obj`) to add a new instance of this display,
+    Call .display(obj) to add a new instance of this display,
     and update existing instances.
-
-    See Also
-    --------
-
-        :func:`display`, :func:`update_display`
-
     """
 
     def __init__(self, display_id=None):
diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
index 42f4cdbf3..b9cee99e5 100644
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -34,6 +34,7 @@
 from IPython.core import magic
 from IPython.core import page
 from IPython.core import prefilter
+from IPython.core import shadowns
 from IPython.core import ultratb
 from IPython.core.alias import Alias, AliasManager
 from IPython.core.autocall import ExitAutocall
@@ -55,7 +56,6 @@
 from IPython.core.prefilter import PrefilterManager
 from IPython.core.profiledir import ProfileDir
 from IPython.core.usage import default_banner
-from IPython.display import display
 from IPython.testing.skipdoctest import skip_doctest
 from IPython.utils import PyColorize
 from IPython.utils import io
@@ -618,7 +618,6 @@ def init_builtins(self):
         # removing on exit or representing the existence of more than one
         # IPython at a time.
         builtin_mod.__dict__['__IPYTHON__'] = True
-        builtin_mod.__dict__['display'] = display
 
         self.builtin_trap = BuiltinTrap(shell=self)
 
@@ -1156,6 +1155,8 @@ def init_user_ns(self):
         ns['_oh'] = self.history_manager.output_hist
         ns['_dh'] = self.history_manager.dir_hist
 
+        ns['_sh'] = shadowns
+
         # user aliases to input and output histories.  These shouldn't show up
         # in %who, as they can have very large reprs.
         ns['In']  = self.history_manager.input_hist_parsed
diff --git a/IPython/core/shadowns.py b/IPython/core/shadowns.py
new file mode 100644
index 000000000..d2d93b61b
--- /dev/null
+++ b/IPython/core/shadowns.py
@@ -0,0 +1,1 @@
+""" Shadow namespace """
\ No newline at end of file
diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py
index 9f9ef779c..14b997047 100644
--- a/IPython/terminal/interactiveshell.py
+++ b/IPython/terminal/interactiveshell.py
@@ -7,7 +7,7 @@
 
 from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC
 from IPython.utils import io
-from IPython.utils.py3compat import input, cast_unicode_py2
+from IPython.utils.py3compat import input
 from IPython.utils.terminal import toggle_set_term_title, set_term_title
 from IPython.utils.process import abbrev_cwd
 from traitlets import (
@@ -101,7 +101,7 @@ def _space_for_menu_changed(self, old, new):
     _pt_app = None
 
     simple_prompt = Bool(_use_simple_prompt,
-        help="""Use `raw_input` for the REPL, without completion and prompt colors.
+        help="""Use `raw_input` for the REPL, without completion, multiline input, and prompt colors.
 
             Useful when controlling IPython as a subprocess, and piping STDIN/OUT/ERR. Known usage are:
             IPython own testing machinery, and emacs inferior-shell integration through elpy.
@@ -227,14 +227,7 @@ def init_prompt_toolkit_cli(self):
             # Fall back to plain non-interactive output for tests.
             # This is very limited, and only accepts a single line.
             def prompt():
-                isp = self.input_splitter
-                prompt_text = "".join(x[1] for x in self.prompts.in_prompt_tokens())
-                prompt_continuation = "".join(x[1] for x in self.prompts.continuation_prompt_tokens())
-                while isp.push_accepts_more():
-                    line = cast_unicode_py2(input(prompt_text))
-                    isp.push(line)
-                    prompt_text = prompt_continuation
-                return isp.source_reset()
+                return input('In [%d]: ' % self.execution_count)
             self.prompt_for_code = prompt
             return
 
diff --git a/IPython/utils/path.py b/IPython/utils/path.py
index a766cbbf7..1e7284d08 100644
--- a/IPython/utils/path.py
+++ b/IPython/utils/path.py
@@ -13,6 +13,7 @@
 import random
 import glob
 from warnings import warn
+from hashlib import md5
 
 from IPython.utils.process import system
 from IPython.utils import py3compat
@@ -364,6 +365,13 @@ def target_update(target,deps,cmd):
     if target_outdated(target,deps):
         system(cmd)
 
+@undoc
+def filehash(path):
+    """Make an MD5 hash of a file, ignoring any differences in line
+    ending characters."""
+    warn("filehash() is deprecated since IPython 4.0", DeprecationWarning, stacklevel=2)
+    with open(path, "rU") as f:
+        return md5(py3compat.str_to_bytes(f.read())).hexdigest()
 
 ENOLINK = 1998
 
diff --git a/docs/source/config/details.rst b/docs/source/config/details.rst
index f1967ded8..2686c4eff 100644
--- a/docs/source/config/details.rst
+++ b/docs/source/config/details.rst
@@ -228,3 +228,45 @@ a :ref:`startup file <startup_files>`::
 For more information on filters and what you can do with the ``event`` object,
 `see the prompt_toolkit docs
 <http://python-prompt-toolkit.readthedocs.io/en/latest/pages/building_prompts.html#adding-custom-key-bindings>`__.
+
+
+Enter to execute
+----------------
+
+In the Terminal IPython shell – which by default uses the ``prompt_toolkit``
+interface, the semantic meaning of pressing the :kbd:`Enter` key can be
+ambiguous. In some case :kbd:`Enter` should execute code, and in others it
+should add a new line. IPython uses heuristics to decide whether to execute or
+insert a new line at cursor position. For example, if we detect that the current
+code is not valid Python, then the user is likely editing code and the right
+behavior is to likely to insert a new line. If the current code is a simple
+statement like `ord('*')`, then the right behavior is likely to execute. Though
+the exact desired semantics often varies from users to users.
+
+As the exact behavior of :kbd:`Enter` is is ambiguous, it has been special cased
+to allow users to completely configure the behavior they like. Hence you can
+have enter always execute code. If you prefer fancier behavior, you need to get
+your hands dirty and read the ``prompt_toolkit`` and IPython documentation
+though. See :ghpull:`10500`, set the
+``c.TerminalInteractiveShell.handle_return`` option and get inspiration from the
+following example that insert new lines only after a pipe (``|``). Place the
+following in your configuration to do so::
+
+    def new_line_after_pipe(shell):
+        # shell is the same as get_ipython()
+        def insert(event):
+            """When the user presses return, insert"""
+            b = event.current_buffer
+            d = b.document
+
+            # if character before cursor is `|`
+            if d.text[d.cursor_position-1] == '|':
+                # insert a new line
+                b.insert_text('\n')
+            else:
+                # otherwise execute.
+                b.accept_action.validate_and_handle(event.cli, b)
+        return insert
+
+    # set the heuristic to our new function
+    c.TerminalInteractiveShell.handle_return = new_line_after_pipe 
diff --git a/docs/source/coredev/index.rst b/docs/source/coredev/index.rst
index 96bb128b9..64c78691e 100644
--- a/docs/source/coredev/index.rst
+++ b/docs/source/coredev/index.rst
@@ -22,11 +22,10 @@ If you are an admin on the IPython repository just mention the **backport bot**
 do the work for you. The bot is evolving so instructions may be different. At
 the time of this writing you can use::
 
-    @meeseeksdev[bot] backport [to <branchname>]
+    @meeseeksdev[bot] backport to <branchname>
 
 The bot will attempt to backport the current pull-request and issue a PR if
-possible. If the milestone is set on the issue you can omit the branch to
-backport to.
+possible.
 
 .. note::
 
diff --git a/docs/source/interactive/plotting.rst b/docs/source/interactive/plotting.rst
index 2bf67b414..8d243d8c2 100644
--- a/docs/source/interactive/plotting.rst
+++ b/docs/source/interactive/plotting.rst
@@ -1,32 +1,7 @@
 .. _plotting:
 
-Rich Outputs
-------------
-
-One of the main feature of IPython when used as a kernel is its ability to
-show rich output. This means that object that can be representing as image,
-sounds, animation, (etc...) can be shown this way if the frontend support it.
-
-In order for this to be possible, you need to use the ``display()`` function,
-that should be available by default on IPython 5.4+ and 6.1+, or that you can
-import with ``from IPython.display import display``. Then use ``display(<your
-object>)`` instead of ``print()``, and if possible your object will be displayed
-with a richer representation. In the terminal of course, there wont be much
-difference as object are most of the time represented by text, but in notebook
-and similar interface you will get richer outputs.
-
-
 Plotting
 --------
-
-.. note::
-
-    Starting with IPython 5.0 and matplotlib 2.0 you can avoid the use of
-    IPython's specific magic and use
-    ``matplotlib.pyplot.ion()``/``matplotlib.pyplot.ioff()`` which have the
-    advantages of working outside of IPython as well.
-
-
 One major feature of the IPython kernel is the ability to display plots that 
 are the output of running code cells. The IPython kernel is designed to work 
 seamlessly with the matplotlib_ plotting library to provide this functionality.
diff --git a/docs/source/whatsnew/github-stats-5.rst b/docs/source/whatsnew/github-stats-5.rst
index 4b9dcf8e0..fddb62125 100644
--- a/docs/source/whatsnew/github-stats-5.rst
+++ b/docs/source/whatsnew/github-stats-5.rst
@@ -3,56 +3,6 @@
 Issues closed in the 5.x development cycle
 ==========================================
 
-
-Issues closed in 5.4
---------------------
-
-GitHub stats for 2017/02/24 - 2017/05/30 (tag: 5.3.0)
-
-These lists are automatically generated, and may be incomplete or contain duplicates.
-
-We closed 8 issues and merged 43 pull requests.
-The full list can be seen `on GitHub <https://github.com/ipython/ipython/issues?q=milestone%3A5.4+>`__
-
-The following 11 authors contributed 64 commits.
-
-* Benjamin Ragan-Kelley
-* Carol Willing
-* Kyle Kelley
-* Leo Singer
-* Luke Pfister
-* Lumir Balhar
-* Matthias Bussonnier
-* meeseeksdev[bot]
-* memeplex
-* Thomas Kluyver
-* Ximin Luo
-
-Issues closed in 5.3
---------------------
-
-GitHub stats for 2017/02/24 - 2017/05/30 (tag: 5.3.0)
-
-These lists are automatically generated, and may be incomplete or contain duplicates.
-
-We closed 6 issues and merged 28 pull requests.
-The full list can be seen `on GitHub <https://github.com/ipython/ipython/issues?q=milestone%3A5.3+>`__
-
-The following 11 authors contributed 53 commits.
-
-* Benjamin Ragan-Kelley
-* Carol Willing
-* Justin Jent
-* Kyle Kelley
-* Lumir Balhar
-* Matthias Bussonnier
-* meeseeksdev[bot]
-* Segev Finer
-* Steven Maude
-* Thomas A Caswell
-* Thomas Kluyver
-
-
 Issues closed in 5.2
 --------------------
 
diff --git a/docs/source/whatsnew/github-stats-6.rst b/docs/source/whatsnew/github-stats-6.rst
index 520c60ce4..08c08de24 100644
--- a/docs/source/whatsnew/github-stats-6.rst
+++ b/docs/source/whatsnew/github-stats-6.rst
@@ -1,46 +1,6 @@
 Issues closed in the 6.x development cycle
 ==========================================
 
-Issues closed in 6.1
---------------------
-
-GitHub stats for 2017/04/19 - 2017/05/30 (tag: 6.0.0)
-
-These lists are automatically generated, and may be incomplete or contain duplicates.
-
-We closed 10 issues and merged 43 pull requests.
-The full list can be seen `on GitHub <https://github.com/ipython/ipython/issues?q=milestone%3A6.1+>`__
-
-The following 26 authors contributed 116 commits.
-
-* Alex Alekseyev
-* Benjamin Ragan-Kelley
-* Brian E. Granger
-* Christopher C. Aycock
-* Dave Willmer
-* David Bradway
-* ICanWaitAndFishAllDay
-* Ignat Shining
-* Jarrod Janssen
-* Joshua Storck
-* Luke Pfister
-* Matthias Bussonnier
-* Matti Remes
-* meeseeksdev[bot]
-* memeplex
-* Ming Zhang
-* Nick Weseman
-* Paul Ivanov
-* Piotr Zielinski
-* ryan thielke
-* sagnak
-* Sang Min Park
-* Srinivas Reddy Thatiparthy
-* Steve Bartz
-* Thomas Kluyver
-* Tory Haavik
-
-
 Issues closed in 6.0
 --------------------
 
diff --git a/docs/source/whatsnew/version5.rst b/docs/source/whatsnew/version5.rst
index b11115ef4..3a4169e91 100644
--- a/docs/source/whatsnew/version5.rst
+++ b/docs/source/whatsnew/version5.rst
@@ -53,19 +53,6 @@ Implement display id and ability to update a given display. This should greatly
 simplify a lot of code by removing the need for widgets and allow other frontend
 to implement things like progress-bars.  See :ghpull:`10048`
 
-Display function
-----------------
-
-The :func:`display() <IPython.display.display>` function is now available by
-default in an IPython session, meaning users can call it on any object to see
-their rich representation. This should allow for better interactivity both at
-the REPL and in notebook environment.
-
-Scripts and library that rely on display and may be run outside of IPython still
-need to import the display function using ``from IPython.display import
-display``. See :ghpull:`10596`
-
-
 Miscs
 -----
 


Test patch:
diff --git a/IPython/core/tests/test_completer.py b/IPython/core/tests/test_completer.py
index 179158862..1beff0ce8 100644
--- a/IPython/core/tests/test_completer.py
+++ b/IPython/core/tests/test_completer.py
@@ -578,22 +578,21 @@ def test_magic_completion_shadowing():
     nt.assert_equal(matches, ["%matplotlib"])
 
 
+
 def test_magic_config():
     ip = get_ipython()
     c = ip.Completer
 
     s, matches = c.complete(None, 'conf')
     nt.assert_in('%config', matches)
-    s, matches = c.complete(None, 'conf')
-    nt.assert_not_in('AliasManager', matches)
     s, matches = c.complete(None, 'config ')
     nt.assert_in('AliasManager', matches)
     s, matches = c.complete(None, '%config ')
     nt.assert_in('AliasManager', matches)
     s, matches = c.complete(None, 'config Ali')
-    nt.assert_list_equal(['AliasManager'], matches)
+    nt.assert_in('AliasManager', matches)
     s, matches = c.complete(None, '%config Ali')
-    nt.assert_list_equal(['AliasManager'], matches)
+    nt.assert_in('AliasManager', matches)
     s, matches = c.complete(None, 'config AliasManager')
     nt.assert_list_equal(['AliasManager'], matches)
     s, matches = c.complete(None, '%config AliasManager')
@@ -603,27 +602,9 @@ def test_magic_config():
     s, matches = c.complete(None, '%config AliasManager.')
     nt.assert_in('AliasManager.default_aliases', matches)
     s, matches = c.complete(None, 'config AliasManager.de')
-    nt.assert_list_equal(['AliasManager.default_aliases'], matches)
+    nt.assert_in('AliasManager.default_aliases', matches)
     s, matches = c.complete(None, 'config AliasManager.de')
-    nt.assert_list_equal(['AliasManager.default_aliases'], matches)
-
-
-def test_magic_color():
-    ip = get_ipython()
-    c = ip.Completer
-
-    s, matches = c.complete(None, 'colo')
-    nt.assert_in('%colors', matches)
-    s, matches = c.complete(None, 'colo')
-    nt.assert_not_in('NoColor', matches)
-    s, matches = c.complete(None, 'colors ')
-    nt.assert_in('NoColor', matches)
-    s, matches = c.complete(None, '%colors ')
-    nt.assert_in('NoColor', matches)
-    s, matches = c.complete(None, 'colors NoCo')
-    nt.assert_list_equal(['NoColor'], matches)
-    s, matches = c.complete(None, '%colors NoCo')
-    nt.assert_list_equal(['NoColor'], matches)
+    nt.assert_in('AliasManager.default_aliases', matches)
 
 
 def test_match_dict_keys():
diff --git a/IPython/core/tests/test_display.py b/IPython/core/tests/test_display.py
index ac716ee03..c639f9228 100644
--- a/IPython/core/tests/test_display.py
+++ b/IPython/core/tests/test_display.py
@@ -13,7 +13,6 @@
 from IPython.core.getipython import get_ipython
 from IPython.utils.tempdir import NamedFileInTemporaryDirectory
 from IPython import paths as ipath
-from IPython.testing.tools import AssertPrints, AssertNotPrints
 
 import IPython.testing.decorators as dec
 
@@ -142,25 +141,6 @@ def test_set_matplotlib_formats_kwargs():
     expected.update(cfg.print_figure_kwargs)
     nt.assert_equal(cell, expected)
 
-def test_display_available():
-    """
-    Test that display is available without import
-
-    We don't really care if it's in builtin or anything else, but it should
-    always be available.
-    """
-    ip = get_ipython()
-    with AssertNotPrints('NameError'):
-        ip.run_cell('display')
-    try:
-        ip.run_cell('del display')
-    except NameError:
-        pass # it's ok, it might be in builtins
-    # even if deleted it should be back
-    with AssertNotPrints('NameError'):
-        ip.run_cell('display')
-
-
 def test_displayobject_repr():
     h = display.HTML('<br />')
     nt.assert_equal(repr(h), '<IPython.core.display.HTML object>')
diff --git a/IPython/core/tests/test_imports.py b/IPython/core/tests/test_imports.py
index 7aa278fb6..88caef0ad 100644
--- a/IPython/core/tests/test_imports.py
+++ b/IPython/core/tests/test_imports.py
@@ -45,6 +45,9 @@ def test_import_prompts():
 def test_import_release():
     from IPython.core import release
 
+def test_import_shadowns():
+    from IPython.core import shadowns
+
 def test_import_ultratb():
     from IPython.core import ultratb
 
diff --git a/IPython/lib/tests/test_pretty.py b/IPython/lib/tests/test_pretty.py
index 934498b55..268de06bb 100644
--- a/IPython/lib/tests/test_pretty.py
+++ b/IPython/lib/tests/test_pretty.py
@@ -6,9 +6,7 @@
 
 
 from collections import Counter, defaultdict, deque, OrderedDict
-import types
-import string
-import unittest
+import types, string
 
 import nose.tools as nt
 
@@ -183,46 +181,44 @@ class SA(object):
 class SB(SA):
     pass
 
-class TestsPretty(unittest.TestCase):
-
-    def test_super_repr(self):
-        # "<super: module_name.SA, None>"
-        output = pretty.pretty(super(SA))
-        self.assertRegex(output, r"<super: \S+.SA, None>")
-
-        # "<super: module_name.SA, <module_name.SB at 0x...>>"
-        sb = SB()
-        output = pretty.pretty(super(SA, sb))
-        self.assertRegex(output, r"<super: \S+.SA,\s+<\S+.SB at 0x\S+>>")
-
-
-    def test_long_list(self):
-        lis = list(range(10000))
-        p = pretty.pretty(lis)
-        last2 = p.rsplit('\n', 2)[-2:]
-        self.assertEqual(last2, [' 999,', ' ...]'])
-
-    def test_long_set(self):
-        s = set(range(10000))
-        p = pretty.pretty(s)
-        last2 = p.rsplit('\n', 2)[-2:]
-        self.assertEqual(last2, [' 999,', ' ...}'])
-
-    def test_long_tuple(self):
-        tup = tuple(range(10000))
-        p = pretty.pretty(tup)
-        last2 = p.rsplit('\n', 2)[-2:]
-        self.assertEqual(last2, [' 999,', ' ...)'])
-
-    def test_long_dict(self):
-        d = { n:n for n in range(10000) }
-        p = pretty.pretty(d)
-        last2 = p.rsplit('\n', 2)[-2:]
-        self.assertEqual(last2, [' 999: 999,', ' ...}'])
-
-    def test_unbound_method(self):
-        output = pretty.pretty(MyObj.somemethod)
-        self.assertIn('MyObj.somemethod', output)
+def test_super_repr():
+    # "<super: module_name.SA, None>"
+    output = pretty.pretty(super(SA))
+    nt.assert_regexp_matches(output, r"<super: \S+.SA, None>")
+
+    # "<super: module_name.SA, <module_name.SB at 0x...>>"
+    sb = SB()
+    output = pretty.pretty(super(SA, sb))
+    nt.assert_regexp_matches(output, r"<super: \S+.SA,\s+<\S+.SB at 0x\S+>>")
+
+
+def test_long_list():
+    lis = list(range(10000))
+    p = pretty.pretty(lis)
+    last2 = p.rsplit('\n', 2)[-2:]
+    nt.assert_equal(last2, [' 999,', ' ...]'])
+
+def test_long_set():
+    s = set(range(10000))
+    p = pretty.pretty(s)
+    last2 = p.rsplit('\n', 2)[-2:]
+    nt.assert_equal(last2, [' 999,', ' ...}'])
+
+def test_long_tuple():
+    tup = tuple(range(10000))
+    p = pretty.pretty(tup)
+    last2 = p.rsplit('\n', 2)[-2:]
+    nt.assert_equal(last2, [' 999,', ' ...)'])
+
+def test_long_dict():
+    d = { n:n for n in range(10000) }
+    p = pretty.pretty(d)
+    last2 = p.rsplit('\n', 2)[-2:]
+    nt.assert_equal(last2, [' 999: 999,', ' ...}'])
+
+def test_unbound_method():
+    output = pretty.pretty(MyObj.somemethod)
+    nt.assert_in('MyObj.somemethod', output)
 
 
 class MetaClass(type):
diff --git a/IPython/utils/tests/test_path.py b/IPython/utils/tests/test_path.py
index d186242e0..4ae2fa9e4 100644
--- a/IPython/utils/tests/test_path.py
+++ b/IPython/utils/tests/test_path.py
@@ -8,7 +8,6 @@
 import shutil
 import sys
 import tempfile
-import unittest
 from contextlib import contextmanager
 from unittest.mock import patch
 from os.path import join, abspath
@@ -318,7 +317,7 @@ def test_unicode_in_filename():
         str(ex)
 
 
-class TestShellGlob(unittest.TestCase):
+class TestShellGlob(object):
 
     @classmethod
     def setUpClass(cls):