Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ipynb tests compatible with ipython 8.3.0+ #3008

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work well because line 146 will fail if the module isn't available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on line 25 there's

pytest.importorskip("IPython", reason="IPython is an optional dependency")

so if IPython isn't available, line 146 is never reached

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