From abc5daed790a792a27c052397c4b48a7d9226ae3 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Tue, 6 Jul 2021 00:34:58 +0200 Subject: [PATCH 1/3] Handle attachments in notebook cells --- pytest_check_links/plugin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pytest_check_links/plugin.py b/pytest_check_links/plugin.py index d9c71a5..af27aad 100644 --- a/pytest_check_links/plugin.py +++ b/pytest_check_links/plugin.py @@ -124,14 +124,16 @@ def _html_from_rst(self): def _items_from_notebook(self): """Yield LinkItems from a notebook""" import nbformat - from nbconvert.filters import markdown2html + from nbconvert.filters.markdown_mistune import IPythonRenderer, MarkdownWithMath nb = nbformat.read(str(self.fspath), as_version=4) for cell_num, cell in enumerate(nb.cells): if cell.cell_type != 'markdown': continue - html = markdown2html(cell.source) + attachments = cell.get('attachments', {}) + renderer = IPythonRenderer(escape=False, attachments=attachments) + html = MarkdownWithMath(renderer=renderer).render(cell.source) basename = 'Cell %i' % cell_num for item in links_in_html(basename, self, html): yield item From e5e5f5f215bdf5772c9743dad4e78924ccb79307 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Tue, 6 Jul 2021 08:33:55 +0200 Subject: [PATCH 2/3] Pin requests-cache --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 7cecff3..31ff041 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,7 +42,7 @@ console_scripts = [options.extras_require] cache = - requests-cache + requests-cache~=0.5.2 [pep8] ignore=E128 From ccfc9a8fd61c87f29e7d033b715c1f2b6ebcb0c3 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Tue, 6 Jul 2021 08:47:47 +0200 Subject: [PATCH 3/3] Do not check for warnings in tests --- test/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_cli.py b/test/test_cli.py index 099c6e6..bc06b71 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -8,7 +8,7 @@ def test_cli_meta(): @pytest.mark.parametrize("example,rc,expected,unexpected", [ - ["httpbin.md", 0, [" 6 passed"], [" failed", " warning"]], + ["httpbin.md", 0, [" 6 passed"], [" failed"]], ["rst.rst", 1, [" 2 failed", " 7 passed"], [" warning"]] ]) def test_cli_pass(testdir, example, rc, expected, unexpected):