X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/50a856970d2453087662a295631d6f24a12bc3a1..9d5edd302003285b5280e3dd209d6299feafb70e:/tests/test_ipynb.py diff --git a/tests/test_ipynb.py b/tests/test_ipynb.py index 473047a..6f6b309 100644 --- a/tests/test_ipynb.py +++ b/tests/test_ipynb.py @@ -1,3 +1,4 @@ +import contextlib from dataclasses import replace import pathlib import re @@ -18,6 +19,8 @@ from black import Mode 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") @@ -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: @@ -415,7 +423,7 @@ def test_ipynb_diff_with_change() -> None: f"--config={EMPTY_CONFIG}", ], ) - expected = "@@ -1,3 +1,3 @@\n %%time\n \n-print('foo')\n" '+print("foo")\n' + expected = "@@ -1,3 +1,3 @@\n %%time\n \n-print('foo')\n+print(\"foo\")\n" assert expected in result.output @@ -494,7 +502,7 @@ def test_ipynb_flag(tmp_path: pathlib.Path) -> None: f"--config={EMPTY_CONFIG}", ], ) - expected = "@@ -1,3 +1,3 @@\n %%time\n \n-print('foo')\n" '+print("foo")\n' + expected = "@@ -1,3 +1,3 @@\n %%time\n \n-print('foo')\n+print(\"foo\")\n" assert expected in result.output