Skip to content

Commit

Permalink
Make ipynb tests compatible with ipython 8.3.0+ (#3008)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Apr 13, 2022
1 parent 96bd428 commit 712f8b3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/test_ipynb.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import contextlib
from dataclasses import replace
import pathlib
import re
Expand All @@ -18,6 +19,8 @@
from _pytest.monkeypatch import MonkeyPatch
from tests.util import DATA_DIR

with contextlib.suppress(ModuleNotFoundError):
import IPython
pytestmark = pytest.mark.jupyter
pytest.importorskip("IPython", reason="IPython is an optional dependency")
pytest.importorskip("tokenize_rt", reason="tokenize-rt is an optional dependency")
Expand Down Expand Up @@ -139,10 +142,15 @@ def test_non_python_magics(src: str) -> None:
format_cell(src, fast=True, mode=JUPYTER_MODE)


@pytest.mark.skipif(
IPython.version_info < (8, 3),
reason="Change in how TransformerManager transforms this input",
)
def test_set_input() -> None:
src = "a = b??"
with pytest.raises(NothingChanged):
format_cell(src, fast=True, mode=JUPYTER_MODE)
expected = "??b"
result = format_cell(src, fast=True, mode=JUPYTER_MODE)
assert result == expected


def test_input_already_contains_transformed_magic() -> None:
Expand Down

0 comments on commit 712f8b3

Please sign in to comment.