repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
ipython | docs/sphinxext/magics.py | .py | import re
from sphinx import addnodes
from sphinx.domains.std import StandardDomain
from sphinx.roles import XRefRole
name_re = re.compile(r"[\w_]+")
def parse_magic(env, sig, signode):
m = name_re.match(sig)
if not m:
raise Exception("Invalid magic command: %s" % sig)
name = "%" + sig
signode... | 47 | 1,496 |
ipython | tests/test_imports.py | .py | # encoding: utf-8
from IPython.testing import decorators as dec
def test_import_backgroundjobs():
from IPython.lib import backgroundjobs
def test_import_deepreload():
from IPython.lib import deepreload
def test_import_demo():
from IPython.lib import demo
| 15 | 273 |
ipython | tests/test_deepreload.py | .py | # -*- coding: utf-8 -*-
"""Test suite for the deepreload module."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import sys
import types
from pathlib import Path
import pytest
from tempfile import TemporaryDirectory
from IPython.lib import deepreload
from IPyt... | 317 | 11,803 |
ipython | tests/test_ipython_directive.py | .py | """Tests for IPython.sphinxext.ipython_directive."""
import io
import os
import tempfile
import pytest
sphinx = pytest.importorskip("sphinx")
from sphinx.application import Sphinx
from IPython.sphinxext.ipython_directive import IPythonDirective
def _build_sphinx(rst_content, builder="html", tags=None):
"""Buil... | 139 | 3,155 |
ipython | tests/test_zzz_autoreload.py | .py | """Tests for autoreload extension."""
# -----------------------------------------------------------------------------
# Copyright (c) 2012 IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# -------... | 1,209 | 40,563 |
ipython | tests/test_debugger.py | .py | """Tests for debugging machinery."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import builtins
import io
import os
import re as re_module
import sys
import platform
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryDirectory
from tex... | 1,994 | 57,989 |
ipython | tests/test_history.py | .py | # coding: utf-8
"""Tests for the IPython tab-completion machinery."""
# -----------------------------------------------------------------------------
# Module imports
# -----------------------------------------------------------------------------
# stdlib
import io
import gc
import os
import sqlite3
import subprocess
... | 858 | 30,272 |
ipython | tests/test_pretty.py | .py | # coding: utf-8
"""Tests for IPython.lib.pretty."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from collections import Counter, defaultdict, deque, OrderedDict, UserList
import os
import pytest
import types
import string
import sys
from IPython.lib import pr... | 612 | 16,196 |
ipython | tests/test_dir2.py | .py | from IPython.utils.dir2 import dir2
import pytest
class Base(object):
x = 1
z = 23
def test_base():
res = dir2(Base())
assert "x" in res
assert "z" in res
assert "y" not in res
assert "__class__" in res
assert res.count("x") == 1
assert res.count("__class__") == 1
def test_Sub... | 67 | 1,446 |
ipython | tests/test_frame.py | .py | """Tests for IPython.utils.frame"""
import collections.abc
from IPython.utils.frame import extract_module_locals
def test_extract_module_locals_returns_tuple():
module, locals_ = extract_module_locals()
assert hasattr(module, "__name__")
# On Python 3.13+, f.f_locals returns FrameLocalsProxy, not dict
... | 17 | 501 |
ipython | tests/test_module_paths.py | .py | # encoding: utf-8
"""Tests for IPython.utils.module_paths.py"""
# -----------------------------------------------------------------------------
# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part ... | 113 | 3,277 |
ipython | tests/test_displayhook.py | .py | import sys
from IPython.testing.tools import AssertPrints, AssertNotPrints
from IPython.core.displayhook import CapturingDisplayHook
from IPython.utils.capture import CapturedIO
def test_output_displayed():
"""Checking to make sure that output is displayed"""
with AssertPrints("2"):
ip.run_cell("1+1"... | 117 | 3,576 |
ipython | tests/tclass.py | .py | """Simple script to be run *twice*, to check reference counting bugs.
See test_run for details."""
import sys
# We want to ensure that while objects remain available for immediate access,
# objects from *previous* runs of the same script get collected, to avoid
# accumulating massive amounts of old references.
clas... | 36 | 920 |
ipython | tests/test_async_helpers.py | .py | """
Test for async helpers.
Should only trigger on python 3.5+ or will have syntax errors.
"""
import contextlib
import sys
from itertools import chain, repeat
from textwrap import dedent, indent
from typing import TYPE_CHECKING
import pytest
from IPython.core.async_helpers import _should_be_async
from IPython.test... | 474 | 10,208 |
ipython | tests/test_decorators_2.py | .py | from IPython.utils import decorators
def test_flag_calls():
@decorators.flag_calls
def f():
pass
assert not f.called
f()
assert f.called
| 12 | 168 |
ipython | tests/test_sentinel.py | .py | """Tests for IPython.utils.sentinel."""
from IPython.utils.sentinel import Sentinel
def test_sentinel_repr():
s = Sentinel("MY_VALUE", "mymodule")
assert repr(s) == "mymodule.MY_VALUE"
def test_sentinel_repr_with_dotted_module():
s = Sentinel("MISSING", "IPython.utils")
assert repr(s) == "IPython.u... | 42 | 1,108 |
ipython | tests/test_interactiveshell.py | .py | # -*- coding: utf-8 -*-
"""Tests for the key interactiveshell module.
Historically the main classes in interactiveshell have been under-tested. This
module should grow as many single-method tests as possible to trap many of the
recurring bugs we seem to encounter with high-level interaction.
"""
# Copyright (c) IPyt... | 1,446 | 41,370 |
ipython | tests/test_guarded_eval.py | .py | import sys
from contextlib import contextmanager
from importlib import import_module
from typing import (
Annotated,
AnyStr,
NamedTuple,
Literal,
NewType,
Optional,
Protocol,
TypeGuard,
Union,
TypedDict,
TypeVar,
List,
Callable,
Any,
Dict,
)
from functools imp... | 1,057 | 28,620 |
ipython | tests/test_page.py | .py | # -----------------------------------------------------------------------------
# Copyright (C) 2010-2011 The IPython Development Team.
#
# Distributed under the terms of the BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# ----------------------------------------------... | 463 | 15,550 |
ipython | tests/test_kitty.py | .py | import subprocess
import sys
import pytest
from pathlib import Path
class DummyStdout:
def write(self, *args, **kwargs):
pass
def flush(self):
pass
class StdoutWithNonCallableIsatty(DummyStdout):
isatty = False
class StdoutTTY(DummyStdout):
def isatty(self):
return True
... | 157 | 4,377 |
ipython | tests/test_encoding.py | .py | """Tests for IPython.utils.encoding."""
import sys
import warnings
from unittest import mock
import pytest
from IPython.utils.encoding import DEFAULT_ENCODING, get_stream_enc, getdefaultencoding
# ---------------------------------------------------------------------------
# get_stream_enc
# -----------------------... | 98 | 3,103 |
ipython | tests/test_autocall.py | .py | """These kinds of tests are less than ideal, but at least they run.
This was an old test that was being run interactively in the top-level tests/
directory, which we are removing. For now putting this here ensures at least
we do run the test, though ultimately this functionality should all be tested
with better-isola... | 158 | 4,198 |
ipython | tests/test_qt_loaders.py | .py | import importlib
import pytest
from IPython.external.qt_loaders import ID
def test_import_denier():
ID.forbid("ipython_denied_module")
with pytest.raises(ImportError, match="disabled by IPython"):
import ipython_denied_module
with pytest.raises(ImportError, match="disabled by IPython"):
im... | 12 | 367 |
ipython | tests/test_generics.py | .py | """Tests for IPython.utils.generics (singledispatch hooks)"""
import warnings
import pytest
from IPython.core.error import TryNext
from IPython.utils import generics
from IPython.utils.generics import complete_object
def test_inspect_object_deprecated():
with pytest.warns(DeprecationWarning, match="inspect_obj... | 64 | 1,703 |
ipython | tests/test_timing.py | .py | """Tests for IPython.utils.timing."""
import pytest
from IPython.utils.timing import clock, clock2, timing, timings, timings_out
def test_clock_returns_float():
t = clock()
assert isinstance(t, float)
assert t >= 0.0
def test_clock2_returns_two_floats():
u, s = clock2()
assert isinstance(u, fl... | 87 | 1,976 |
ipython | tests/test_magics_packaging.py | .py | """Tests for IPython.core.magics.packaging (%pip, %conda, %mamba, %micromamba, %uv).
No package manager is ever executed. ``ip.system`` is replaced by a recorder
so only the constructed command lines are asserted.
"""
import shlex
import sys
from pathlib import Path
import pytest
from IPython.testing.decorators imp... | 192 | 7,044 |
ipython | tests/test_shortcuts.py | .py | import pytest
import sys
import time
from IPython.terminal.interactiveshell import PtkHistoryAdapter
from IPython.terminal.shortcuts.auto_suggest import (
accept,
accept_or_jump_to_end,
accept_token,
accept_character,
accept_word,
accept_and_keep_cursor,
discard,
llm_autosuggestion,
... | 1,188 | 38,590 |
ipython | tests/test_display_2.py | .py | # Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import json
import os
import sys
import warnings
from pathlib import Path
from unittest import mock
import pytest
from IPython import display
from IPython.core.display import ImageFormat
from IPython.core.getipython... | 608 | 19,158 |
ipython | tests/test_logger_unit.py | .py | """Unit tests for IPython.core.logger.Logger"""
import os
import pytest
from IPython.core.logger import Logger
@pytest.fixture
def logger(tmp_path):
return Logger(home_dir=str(tmp_path))
# ---------------------------------------------------------------------------
# logmode property
# -----------------------... | 193 | 5,744 |
ipython | tests/test_process.py | .py | """
Tests for platutils.py
"""
# -----------------------------------------------------------------------------
# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
# -------------... | 241 | 6,933 |
ipython | tests/test_tempdir.py | .py | # -----------------------------------------------------------------------------
# Copyright (C) 2012- The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
# -------------------------------------------------... | 31 | 1,117 |
ipython | tests/test_pickleshare.py | .py | """Tests for the vendored pickleshare module."""
import errno
from pathlib import Path
import pytest
from IPython.external.pickleshare import PickleShareDB, PickleShareLink, gethashfile
@pytest.fixture
def db(tmp_path):
return PickleShareDB(tmp_path / "pickleshare")
def test_init_creates_directory(tmp_path):... | 320 | 9,940 |
ipython | tests/test_formatters.py | .py | """Tests for the Formatters."""
from math import pi
try:
import numpy
except:
numpy = None
import pytest
from IPython import get_ipython
from traitlets.config import Config
from IPython.core.formatters import (
PlainTextFormatter,
HTMLFormatter,
PDFFormatter,
_mod_name_key,
DisplayFormatt... | 610 | 15,546 |
ipython | tests/test_importstring.py | .py | """Tests for IPython.utils.importstring."""
# -----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
# -----... | 66 | 1,701 |
ipython | tests/test_display.py | .py | """Tests for IPython.lib.display."""
# -----------------------------------------------------------------------------
# Copyright (c) 2012, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# ------... | 342 | 12,046 |
ipython | tests/test_run.py | .py | # encoding: utf-8
"""Tests for code execution (%run and related), which is particularly tricky.
Because of how %run manages namespaces, and the fact that we are trying here to
verify subtle object deletion and reference counting issues, the %run tests
will be kept in this separate file. This makes it easier to aggreg... | 624 | 18,316 |
ipython | tests/test_shellapp.py | .py | # -*- coding: utf-8 -*-
"""Tests for shellapp module.
Authors
-------
* Bradley Froehle
"""
# -----------------------------------------------------------------------------
# Copyright (C) 2012 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYIN... | 144 | 4,316 |
ipython | tests/test_storemagic.py | .py | import tempfile, os
from pathlib import Path
import pytest
from traitlets.config.loader import Config
from IPython.core.error import UsageError
def setup_module():
ip.run_line_magic("load_ext", "storemagic")
def test_store_restore():
assert "bar" not in ip.user_ns, "Error: some other test leaked `bar` in ... | 207 | 7,030 |
ipython | tests/test_ultratb.py | .py | # encoding: utf-8
"""Tests for IPython.core.ultratb"""
import functools
import io
import os.path
import platform
import re
import sys
import traceback
from textwrap import dedent
import pytest
from tempfile import TemporaryDirectory
from IPython.core.ultratb import VerboseTB, FormattedTB
from IPython.testing import ... | 528 | 13,490 |
ipython | tests/test_pt_inputhooks.py | .py | import os
import importlib
import pytest
from IPython.terminal.pt_inputhooks import set_qt_api, get_inputhook_name_and_func
guis_avail = []
def _get_qt_vers():
"""If any version of Qt is available, this will populate `guis_avail` with 'qt' and 'qtx'. Due
to the import mechanism, we can't import multiple v... | 51 | 1,599 |
ipython | tests/test_completer.py | .py | # encoding: utf-8
"""Tests for the IPython tab-completion machinery."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import os
import pytest
import sys
import textwrap
import types
import random
from importlib.metadata import version
from contextlib import con... | 2,922 | 89,745 |
ipython | tests/test_guisupport.py | .py | """Tests for IPython.lib.guisupport.
These tests use fake toolkit modules/objects injected into ``sys.modules`` so
that no real GUI toolkit (wx, Qt) is imported or started.
"""
import sys
import types
import pytest
from IPython.lib import guisupport
# ---------------------------------------------------------------... | 238 | 7,848 |
ipython | tests/test_backgroundjobs.py | .py | """Tests for pylab tools module."""
# -----------------------------------------------------------------------------
# Copyright (c) 2011, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# -------... | 282 | 7,977 |
ipython | tests/test_application.py | .py | # coding: utf-8
"""Tests for IPython.core.application"""
import os
import sys
import tempfile
from tempfile import TemporaryDirectory
import pytest
from traitlets import Unicode
from traitlets.config import Config
from IPython.core.application import (
LOGGING_CRITICAL,
LOGGING_DEBUG,
BaseIPythonApplica... | 393 | 13,897 |
ipython | tests/test_oinspect.py | .py | from contextlib import contextmanager
from inspect import signature, Signature, Parameter
import functools
import inspect
import os
import pytest
import re
import sys
from IPython.core import oinspect
from IPython.testing.tools import AssertPrints, AssertNotPrints
from IPython.utils.path import compress_user
# ----... | 652 | 17,474 |
ipython | tests/fake_llm.py | .py | import asyncio
from time import sleep
try:
from jupyter_ai_magics.providers import BaseProvider
from langchain_community.llms import FakeListLLM
except ImportError:
class BaseProvider:
pass
class FakeListLLM:
pass
FIBONACCI = """\
def fib(n):
if n < 2: return n
return fib(n ... | 103 | 2,947 |
ipython | tests/test_debugger_backport.py | .py | """Tests for IPython.core.debugger_backport.
``PdbClosureBackport`` is a backport of the CPython 3.13 pdb changes making
closures work in the debugger (gh-83151). It is mixed into
``IPython.core.debugger.Pdb`` on Python < 3.13 only, so the tests going
through ``Pdb`` commands are skipped on newer versions, while the
... | 172 | 5,140 |
ipython | tests/test_capture.py | .py | # encoding: utf-8
"""Tests for IPython.utils.capture"""
# -----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this softwa... | 181 | 5,597 |
ipython | tests/test_io.py | .py | # encoding: utf-8
"""Tests for io.py"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import sys
from io import StringIO
import pytest
from IPython.utils.io import Tee, capture_output
def test_tee_simple():
"Very simple check with stdout only"
chan = ... | 72 | 1,529 |
ipython | tests/test_error.py | .py | """Tests for IPython.core.error exception hierarchy."""
import pytest
from IPython.core.error import (
IPythonCoreError,
InputRejected,
StdinNotImplementedError,
TryNext,
UsageError,
)
def test_ipython_core_error_is_exception():
assert issubclass(IPythonCoreError, Exception)
def test_try_n... | 77 | 1,931 |
ipython | tests/test_magic.py | .py | # -*- coding: utf-8 -*-
"""Tests for various magic functions."""
import collections
import gc
import io
import json
import os
import platform
import re
import shlex
import signal
import sys
import warnings
from importlib import invalidate_caches
from io import StringIO
from pathlib import Path
from time import sleep
f... | 1,988 | 56,220 |
ipython | tests/test_doctb.py | .py | """Tests for IPython.core.doctb (doc-oriented traceback formatter)."""
import io
import sys
import pytest
import stack_data
from IPython.core.doctb import DocTB, _format_traceback_lines
from IPython.utils.PyColorize import theme_table
def _divide():
x = 1
y = 0
return x / y
def _call_divide():
re... | 320 | 10,015 |
ipython | tests/test_interactivshell.py | .py | # -*- coding: utf-8 -*-
"""Tests for the TerminalInteractiveShell and related pieces."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import sys
import os
import pytest
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from IPython.testing import... | 234 | 6,825 |
ipython | tests/test_ipstruct.py | .py | """Tests for IPython.utils.ipstruct.Struct"""
import pytest
from IPython.utils.ipstruct import Struct
def test_init_empty():
s = Struct()
assert s == {}
def test_init_kwargs():
s = Struct(a=1, b=2)
assert s["a"] == 1
assert s.a == 1
def test_init_from_dict():
s = Struct({"x": 10, "y": 20})... | 144 | 2,888 |
ipython | tests/test_pycolorize.py | .py | # coding: utf-8
"""Test suite for our color utilities.
Authors
-------
* Min RK
"""
# -----------------------------------------------------------------------------
# Copyright (C) 2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING.txt, ... | 72 | 1,812 |
ipython | tests/test_iplib.py | .py | """Tests for the key interactiveshell module, where the main ipython class is defined."""
import stack_data
import sys
SV_VERSION = tuple([int(x) for x in stack_data.__version__.split(".")[0:2]])
def test_reset():
"""reset must clear most namespaces."""
# Check that reset runs without error
ip.reset()
... | 244 | 6,477 |
ipython | tests/test_embed.py | .py | """Test embedding of IPython"""
# -----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
# ------------------... | 504 | 17,725 |
ipython | tests/test_demo.py | .py | # -*- coding: utf-8 -*-
"""Tests for the IPython.lib.demo module."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import builtins
import io
import pytest
from IPython.lib import demo as demo_module
from IPython.lib.demo import (
ClearDemo,
ClearIPDemo,... | 435 | 12,485 |
ipython | tests/test_terminal_utils.py | .py | """Tests for IPython.utils.terminal"""
import pytest
from unittest import mock
import IPython.utils.terminal as terminal_mod
from IPython.utils.terminal import (
toggle_set_term_title,
set_term_title,
restore_term_title,
get_terminal_size,
)
def test_get_terminal_size_returns_tuple():
result = ge... | 83 | 2,438 |
ipython | tests/bad_all.py | .py | """Module with bad __all__
To test https://github.com/ipython/ipython/issues/9678
"""
def evil():
pass
def puppies():
pass
__all__ = [
evil, # Bad
"puppies", # Good
]
| 19 | 192 |
ipython | tests/test_inputtransformer2.py | .py | """Tests for the token-based transformers in IPython.core.inputtransformer2
Line-based transformers are the simpler ones; token-based transformers are
more complex. See test_inputtransformer2_line for tests for line-based
transformations.
"""
import platform
import string
import sys
from textwrap import dedent
impor... | 454 | 11,892 |
ipython | tests/test_prefilter.py | .py | """Tests for input manipulation machinery."""
# -----------------------------------------------------------------------------
# Imports
# -----------------------------------------------------------------------------
import pytest
from IPython.core.prefilter import AutocallChecker
# ----------------------------------... | 155 | 4,852 |
ipython | tests/test_utils_misc.py | .py | """Tests for small IPython.utils modules: data, timing, frame and encoding."""
import importlib
import sys
import time
import types
import pytest
from IPython.testing.decorators import skip_win32
from IPython.utils import data as data_mod
from IPython.utils import encoding as encoding_mod
from IPython.utils import ... | 247 | 7,878 |
ipython | tests/test_clipboard.py | .py | import subprocess
import sys
import types
import pytest
from IPython.core.error import TryNext
from IPython.lib import clipboard
from IPython.lib.clipboard import (
ClipboardEmpty,
osx_clipboard_get,
tkinter_clipboard_get,
wayland_clipboard_get,
win32_clipboard_get,
)
from IPython.testing.decorato... | 264 | 7,511 |
ipython | tests/test_ptutils.py | .py | """Tests for IPython.terminal.ptutils."""
import os
import sys
import pytest
from IPython.testing.decorators import skip_win32
from unittest.mock import Mock, patch
from prompt_toolkit.document import Document
from IPython.core.completer import provisionalcompleter
from IPython.terminal.ptutils import (
IPytho... | 263 | 8,865 |
ipython | tests/refbug.py | .py | """Minimal script to reproduce our nasty reference counting bug.
The problem is related to https://github.com/ipython/ipython/issues/141
The original fix for that appeared to work, but John D. Hunter found a
matplotlib example which, when run twice in a row, would break. The problem
were references held by open figu... | 46 | 1,498 |
ipython | tests/test_crashhandler.py | .py | """Tests for IPython.core.crashhandler"""
import sys
from unittest.mock import MagicMock
import pytest
from IPython.core import crashhandler
from IPython.core.crashhandler import CrashHandler, crash_handler_lite
from IPython.core.interactiveshell import InteractiveShell
class FakeApp:
"""Minimal stand-in for a... | 214 | 7,326 |
ipython | tests/test_openpy.py | .py | import io
import os.path
from IPython.utils import openpy
mydir = os.path.dirname(__file__)
nonascii_path = os.path.join(mydir, "nonascii.py")
def test_detect_encoding():
with open(nonascii_path, "rb") as f:
enc, lines = openpy.detect_encoding(f.readline)
assert enc == "iso-8859-5"
def test_read_f... | 39 | 1,202 |
ipython | tests/test_inputtransformer2_line.py | .py | """Tests for the line-based transformers in IPython.core.inputtransformer2
Line-based transformers are the simpler ones; token-based transformers are
more complex. See test_inputtransformer2 for tests for token-based transformers.
"""
import pytest
from IPython.core import inputtransformer2 as ipt2
CELL_MAGIC = (
... | 350 | 5,785 |
ipython | tests/test_payload.py | .py | """Tests for IPython.core.payload and IPython.core.payloadpage."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import pytest
from IPython.core import payloadpage
from IPython.core.payload import PayloadManager
# -----------------------------------------------... | 143 | 4,228 |
ipython | tests/test_magics_pylab.py | .py | """Tests for the %matplotlib and %pylab magics (IPython.core.magics.pylab)."""
import pytest
matplotlib = pytest.importorskip("matplotlib")
matplotlib.use("Agg")
from IPython.core.magics import pylab as pylab_magics_module
@pytest.fixture
def fake_enable_pylab(monkeypatch):
"""Replace shell.enable_pylab with a... | 130 | 4,244 |
ipython | tests/test_path.py | .py | # encoding: utf-8
"""Tests for IPython.utils.path.py"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import os
import shutil
import sys
import tempfile
from contextlib import contextmanager
from importlib import reload
from os.path import abspath, join
from unit... | 508 | 15,669 |
ipython | tests/test_syspathcontext.py | .py | """Tests for IPython.utils.syspathcontext."""
import sys
import pytest
from IPython.utils.syspathcontext import prepended_to_syspath
_FAKE_DIR = "/tmp/fake_test_dir_ipython_xyz_99999"
def test_prepended_adds_dir_to_sys_path():
assert _FAKE_DIR not in sys.path
with prepended_to_syspath(_FAKE_DIR):
... | 75 | 1,996 |
ipython | tests/test_display_functions.py | .py | """Tests for IPython.core.display_functions."""
import pytest
from unittest import mock
from IPython.core.display_functions import (
DisplayHandle,
_merge,
_new_id,
display,
update_display,
)
# ---------------------------------------------------------------------------
# _merge
# ---------------... | 222 | 5,912 |
ipython | tests/test_wildcard.py | .py | """Some tests for the wildcard utilities."""
import pytest
from IPython.utils import wildcard
class obj_t(object):
pass
root = obj_t()
l = ["arna", "abel", "ABEL", "active", "bob", "bark", "abbot"]
q = ["kate", "loop", "arne", "vito", "lucifer", "koppel"]
for x in l:
o = obj_t()
setattr(root, x, o)
... | 119 | 3,447 |
ipython | tests/test_events.py | .py | import pytest
from unittest.mock import Mock
from IPython.core import events
import IPython.testing.tools as tt
@events._define_event
def ping_received():
pass
@events._define_event
def event_with_argument(argument):
pass
@pytest.fixture
def em():
return events.EventManager(
get_ipython(),
... | 89 | 1,898 |
ipython | tests/test_alias.py | .py | from IPython.utils.capture import capture_output
import pytest
def test_alias_lifecycle():
name = "test_alias1"
cmd = 'echo "Hello"'
am = _ip.alias_manager
am.clear_aliases()
am.define_alias(name, cmd)
assert am.is_alias(name)
assert am.retrieve_alias(name) == cmd
assert (name, cmd) i... | 69 | 1,988 |
ipython | tests/test_text_utils.py | .py | """Parametrized tests for IPython.utils.text utility functions."""
import pytest
from IPython.utils.text import (
indent,
list_strings,
marquee,
format_screen,
dedent,
get_text_list,
)
# ---------------------------------------------------------------------------
# indent
# --------------------... | 140 | 4,532 |
ipython | tests/test_historyapp.py | .py | # coding: utf-8
"""Tests for IPython.core.historyapp"""
import sqlite3
import sys
from contextlib import closing
import pytest
from traitlets.config.configurable import SingletonConfigurable
from IPython.core.historyapp import HistoryApp, HistoryClear, HistoryTrim
def _clear_singleton(inst):
"""Unregister a S... | 178 | 6,063 |
ipython | tests/test_pylabtools.py | .py | """Tests for pylab tools module."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import sys
from binascii import a2b_base64
from io import BytesIO
import pytest
matplotlib = pytest.importorskip("matplotlib")
matplotlib.use("Agg")
from matplotlib.figure import... | 412 | 12,360 |
ipython | tests/test_contexts.py | .py | """Tests for IPython.utils.contexts."""
import pytest
from IPython.utils.contexts import preserve_keys
def test_preserve_keys_restores_existing_key():
d = {"a": 1, "b": 2}
with preserve_keys(d, "a"):
d["a"] = 99
assert d["a"] == 1
def test_preserve_keys_deletes_new_key():
d = {"a": 1}
... | 73 | 1,677 |
ipython | tests/test_ipunittest.py | .py | """Tests for IPython's test support utilities.
These are decorators that allow standalone functions and docstrings to be seen
as tests by unittest, replicating some of nose's functionality. Additionally,
IPython-syntax docstrings can be auto-converted to '>>>' so that ipython
sessions can be copy-pasted as tests.
Th... | 136 | 3,365 |
ipython | tests/test_ipapp.py | .py | """Tests for IPython.terminal.ipapp, exercised in-process.
These tests build real ``TerminalIPythonApp`` instances pointed at the
temporary IPYTHONDIR set up by ``tests/conftest.py``. Because
``TerminalInteractiveShell`` is a singleton (created by conftest), every app
attaches to the same shell; the ``make_app`` fixt... | 442 | 14,903 |
ipython | tests/test_handlers.py | .py | """Tests for input handlers."""
# -----------------------------------------------------------------------------
# Module imports
# -----------------------------------------------------------------------------
# our own packages
from IPython.core import autocall
from IPython.testing import tools as tt
import pytest
fr... | 80 | 2,954 |
ipython | tests/test_sysinfo.py | .py | # coding: utf-8
"""Test suite for our sysinfo utilities."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import json
import sys
import platform
import pytest
from IPython.utils import sysinfo
def test_json_getsysinfo():
"""Test that get_sys_info returns ... | 68 | 1,501 |
ipython | tests/test_editorhooks.py | .py | """Test installing editor hooks"""
import sys
from unittest import mock
import pytest
from IPython import get_ipython
from IPython.core.error import TryNext
from IPython.lib import editorhooks
def test_install_editor():
called = []
def fake_popen(*args, **kwargs):
called.append(
{
... | 127 | 4,022 |
ipython | tests/test_magic_terminal.py | .py | """Tests for various magic functions specific to the terminal frontend."""
# -----------------------------------------------------------------------------
# Imports
# -----------------------------------------------------------------------------
import sys
from io import StringIO
import pytest
from IPython.testing i... | 229 | 5,280 |
ipython | tests/print_argv.py | .py | import sys
print(sys.argv[1:])
| 4 | 32 |
ipython | tests/test_help.py | .py | """Test help output of various IPython entry points"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import pytest
import IPython.testing.tools as tt
def test_ipython_help():
tt.help_all_output_test()
def test_profile_help():
tt.help_all_output_test("... | 37 | 728 |
ipython | tests/test_strdispatch.py | .py | """Tests for IPython.utils.strdispatch."""
import pytest
from IPython.utils.strdispatch import StrDispatch
def test_s_matches_exact_string():
dis = StrDispatch()
dis.add_s("hello", "value1")
matches = list(dis.s_matches("hello"))
assert "value1" in matches
def test_s_matches_no_match_returns_empty... | 88 | 2,275 |
ipython | tests/test_debug_magic.py | .py | """Test embedding of IPython"""
# -----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
# ------------------... | 88 | 2,533 |
ipython | tests/test_tips.py | .py | from IPython.core.tips import _tips
import importlib
import importlib.util
import os
import sys
import types
from datetime import datetime
import pytest
import IPython.core.tips as tips_mod
all_tips = _tips["random"] + list(_tips["every_year"].values())
@pytest.mark.skipif(os.name != "nt", reason="Windows console... | 99 | 3,373 |
ipython | tests/test_decorators.py | .py | """Tests for the decorators we've created for IPython."""
# Module imports
# Std lib
import inspect
import sys
# Our own
from IPython.testing import decorators as dec
from IPython.testing.skipdoctest import skip_doctest
from IPython.utils.text import dedent
# ---------------------------------------------------------... | 155 | 3,663 |
ipython | tests/test_paths.py | .py | import errno
import os
import shutil
import tempfile
import warnings
from unittest.mock import patch
from tempfile import TemporaryDirectory
from testpath import assert_isdir, assert_isfile, modified_env
from IPython import paths
from IPython.testing.decorators import skip_win32
TMP_TEST_DIR = os.path.realpath(tempf... | 230 | 7,268 |
ipython | tests/test_completerlib.py | .py | # -*- coding: utf-8 -*-
"""Tests for completerlib."""
import os
import sys
from os.path import join
from tempfile import TemporaryDirectory
import pytest
from IPython.core.completerlib import magic_run_completer, module_completion, try_import
from IPython.testing.decorators import onlyif_unicode_paths
class MockEv... | 138 | 4,194 |
ipython | tests/test_splitinput.py | .py | # coding: utf-8
import re
from IPython.core.oinspect import OInfo
from IPython.core.splitinput import split_user_input, LineInfo
import pytest
tests = [
("x=1", ("", "", "x", "=1")),
("?", ("", "?", "", "")),
("??", ("", "??", "", "")),
(" ?", (" ", "?", "", "")),
(" ??", (" ", "??", "", "")),
... | 95 | 2,977 |
ipython | tests/test_compilerop.py | .py | # coding: utf-8
"""Tests for the compilerop module."""
# -----------------------------------------------------------------------------
# Copyright (C) 2010-2011 The IPython Development Team.
#
# Distributed under the terms of the BSD License.
#
# The full license is in the file COPYING.txt, distributed with this sof... | 66 | 1,808 |
ipython | tests/test_macro.py | .py | """Tests for IPython.core.macro"""
import pickle
import pytest
from IPython.core.macro import Macro
def test_macro_stores_code_with_trailing_newline():
m = Macro("a = 1")
assert m.value == "a = 1\n"
def test_macro_multiline():
m = Macro("a = 1\nb = 2")
assert m.value == "a = 1\nb = 2\n"
def tes... | 108 | 2,514 |
ipython | tests/test_magics_code.py | .py | # coding: utf-8
"""Tests for the code management magics (%save, %load, %pastebin, %edit)."""
import importlib.util
import os
from pathlib import Path
from urllib.parse import parse_qs
import pytest
from IPython.testing.decorators import skip_win32
from IPython.core.error import StdinNotImplementedError, TryNext, Us... | 568 | 19,581 |
ipython | tests/test_logger.py | .py | # -*- coding: utf-8 -*-
"""Test IPython.core.logger"""
import os.path
import re
import pytest
from tempfile import TemporaryDirectory
from IPython.core.logger import Logger
def test_logstart_inaccessible_file():
with pytest.raises(IOError):
_ip.logger.logstart(logfname="/") # Opening that filename wil... | 280 | 8,802 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.