-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test that Jupytext refuses to open a non-unicode file (api, cli & jup…
…yter) (#897)
- Loading branch information
Showing
5 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"""Jupytext's version number""" | ||
|
||
__version__ = "1.13.4" | ||
__version__ = "1.13.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
jupytext: | ||
formats: ipynb,md:myst | ||
text_representation: | ||
extension: .md | ||
format_name: myst | ||
format_version: 0.13 | ||
jupytext_version: 1.11.5 | ||
kernelspec: | ||
display_name: Python 3 (ipykernel) | ||
language: python | ||
name: python3 | ||
--- | ||
Et voilà! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Jupytext should refuse to open a file with invalid content""" | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
from tornado.web import HTTPError | ||
|
||
from jupytext import TextFileContentsManager, read | ||
from jupytext.cli import jupytext as jupytext_cli | ||
|
||
from .utils import skip_on_windows | ||
|
||
|
||
@pytest.fixture | ||
def invalid_md_file(): | ||
return Path(__file__).parent / "invalid_file_896.md" | ||
|
||
|
||
@skip_on_windows | ||
def test_read_invalid_md_file_fails(invalid_md_file): | ||
with open(invalid_md_file) as fp: | ||
with pytest.raises(UnicodeDecodeError): | ||
read(fp) | ||
|
||
|
||
def test_convert_invalid_md_file_fails(invalid_md_file): | ||
with pytest.raises(UnicodeDecodeError): | ||
jupytext_cli(["--to", "ipynb", str(invalid_md_file)]) | ||
|
||
|
||
def test_open_invalid_md_file_fails(invalid_md_file, tmp_path): | ||
cm = TextFileContentsManager() | ||
cm.root_dir = str(invalid_md_file.parent) | ||
|
||
with pytest.raises(HTTPError, match="invalid_file_896.md is not UTF-8 encoded"): | ||
cm.get(invalid_md_file.name) |