diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 78ae657..4d71116 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v6.0.0 hooks: - id: check-json - id: check-yaml @@ -14,7 +14,7 @@ repos: exclude: ^tests/.*\.txt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.6 + rev: v0.14.9 hooks: - id: ruff args: [--fix] diff --git a/pytest_notebook/__init__.py b/pytest_notebook/__init__.py index d456026..b6a4499 100644 --- a/pytest_notebook/__init__.py +++ b/pytest_notebook/__init__.py @@ -1,2 +1,3 @@ """A pytest plugin for testing Jupyter Notebooks.""" + __version__ = "0.10.0" diff --git a/pytest_notebook/diffing.py b/pytest_notebook/diffing.py index a8f3003..f4518ed 100644 --- a/pytest_notebook/diffing.py +++ b/pytest_notebook/diffing.py @@ -1,4 +1,5 @@ """Diffing of notebooks.""" + import copy import operator import re diff --git a/pytest_notebook/example_nbs/coverage.ipynb b/pytest_notebook/example_nbs/coverage.ipynb index d9a52db..08b1c0c 100644 --- a/pytest_notebook/example_nbs/coverage.ipynb +++ b/pytest_notebook/example_nbs/coverage.ipynb @@ -14,10 +14,9 @@ } ], "source": [ - "\n", "from pytest_notebook import __version__\n", - "from pytest_notebook.notebook import create_notebook\n", - "print(__version__)\n" + "\n", + "print(__version__)" ] } ], diff --git a/pytest_notebook/example_nbs/example1.ipynb b/pytest_notebook/example_nbs/example1.ipynb index db4fe97..d8bd14f 100644 --- a/pytest_notebook/example_nbs/example1.ipynb +++ b/pytest_notebook/example_nbs/example1.ipynb @@ -12,9 +12,7 @@ "execution_count": 2, "metadata": {}, "outputs": [], - "source": [ - "from IPython import display" - ] + "source": [] }, { "cell_type": "code", @@ -31,8 +29,8 @@ } ], "source": [ - "print('hallo1')\n", - "print('hallo2')" + "print(\"hallo1\")\n", + "print(\"hallo2\")" ] } ], diff --git a/pytest_notebook/example_nbs/example1_pass.ipynb b/pytest_notebook/example_nbs/example1_pass.ipynb index 02518ce..ca4ced6 100644 --- a/pytest_notebook/example_nbs/example1_pass.ipynb +++ b/pytest_notebook/example_nbs/example1_pass.ipynb @@ -12,9 +12,7 @@ "execution_count": 1, "metadata": {}, "outputs": [], - "source": [ - "from IPython import display" - ] + "source": [] }, { "cell_type": "code", @@ -31,8 +29,8 @@ } ], "source": [ - "print('hallo1')\n", - "print('hallo2')" + "print(\"hallo1\")\n", + "print(\"hallo2\")" ] } ], diff --git a/pytest_notebook/example_nbs/example2.ipynb b/pytest_notebook/example_nbs/example2.ipynb index d9184de..986d113 100644 --- a/pytest_notebook/example_nbs/example2.ipynb +++ b/pytest_notebook/example_nbs/example2.ipynb @@ -31,8 +31,8 @@ } ], "source": [ - "print('hallo1')\n", - "print('hallo2')" + "print(\"hallo1\")\n", + "print(\"hallo2\")" ] }, { @@ -118,7 +118,7 @@ ], "source": [ "# code cell + png\n", - "display.Image(filename='128x128.png', width=200, unconfined=True)" + "display.Image(filename=\"128x128.png\", width=200, unconfined=True)" ] }, { @@ -145,7 +145,7 @@ ], "source": [ "# code cell + jpg\n", - "display.Image(filename='128x128.jpg', width=200, unconfined=True)" + "display.Image(filename=\"128x128.jpg\", width=200, unconfined=True)" ] }, { @@ -178,9 +178,13 @@ } ], "source": [ - "print('before exception')\n", + "print(\"before exception\")\n", + "\n", + "\n", "def func(b):\n", - " raise ValueError('there was an error')\n", + " raise ValueError(\"there was an error\")\n", + "\n", + "\n", "for i in range(10):\n", " func(i)" ] diff --git a/pytest_notebook/execution.py b/pytest_notebook/execution.py index 406af83..f9f577d 100644 --- a/pytest_notebook/execution.py +++ b/pytest_notebook/execution.py @@ -1,4 +1,5 @@ """Execution of notebooks.""" + from contextlib import nullcontext import copy import json @@ -177,8 +178,7 @@ class CoverageError(Exception): def from_exec_reply(cls, phase, reply): """Instantiate from an execution reply.""" return cls( - f"An error occurred while executing coverage {phase}:\n" - f"{reply['content']}" + f"An error occurred while executing coverage {phase}:\n{reply['content']}" ) @classmethod @@ -188,7 +188,7 @@ def from_cell_output(cls, phase, output): return cls( f"An error occurred while executing coverage {phase}:\n" f"{traceback}\n" - f"{output.get('ename', '')}: { output.get('evalue', '')}" + f"{output.get('ename', '')}: {output.get('evalue', '')}" ) diff --git a/pytest_notebook/ipy_magic.py b/pytest_notebook/ipy_magic.py index ea4b922..0301e9a 100644 --- a/pytest_notebook/ipy_magic.py +++ b/pytest_notebook/ipy_magic.py @@ -4,6 +4,7 @@ then ``%pytest`` and ``%%pytest`` can be accessed. """ + # TODO post solution to stackoverflow: # https://stackoverflow.com/questions/41304311/running-pytest-test-functions-inside-a-jupyter-notebook import os @@ -20,7 +21,7 @@ def parse_cell_content( - cell: Union[str, None] + cell: Union[str, None], ) -> Tuple[List[str], List[str], List[str]]: """Parse the cell contents. diff --git a/pytest_notebook/nb_regression.py b/pytest_notebook/nb_regression.py index a7b04ea..8cf99b5 100644 --- a/pytest_notebook/nb_regression.py +++ b/pytest_notebook/nb_regression.py @@ -1,4 +1,5 @@ """Jupyter Notebook Regression Test Class.""" + import copy import logging import os diff --git a/pytest_notebook/notebook.py b/pytest_notebook/notebook.py index 21a72bf..1d7c211 100644 --- a/pytest_notebook/notebook.py +++ b/pytest_notebook/notebook.py @@ -1,4 +1,5 @@ """Module for working with notebook.""" + import copy from functools import lru_cache diff --git a/pytest_notebook/plugin.py b/pytest_notebook/plugin.py index ab9cd3e..a86d84b 100644 --- a/pytest_notebook/plugin.py +++ b/pytest_notebook/plugin.py @@ -10,6 +10,7 @@ - https://docs.pytest.org/en/latest/_modules/_pytest/hookspec.html """ + import os import shlex diff --git a/pytest_notebook/post_processors.py b/pytest_notebook/post_processors.py index 89010cf..d85bfec 100644 --- a/pytest_notebook/post_processors.py +++ b/pytest_notebook/post_processors.py @@ -3,6 +3,7 @@ All functions should take (notebook, resources) as input, and output a (new notebook, resources). """ + import copy import functools import logging diff --git a/pytest_notebook/utils.py b/pytest_notebook/utils.py index aca9121..9504b32 100644 --- a/pytest_notebook/utils.py +++ b/pytest_notebook/utils.py @@ -1,4 +1,5 @@ """Utility functions.""" + import os import textwrap import warnings diff --git a/tests/raw_files/coverage_test/call_package.ipynb b/tests/raw_files/coverage_test/call_package.ipynb index a2ef213..2dc10ec 100644 --- a/tests/raw_files/coverage_test/call_package.ipynb +++ b/tests/raw_files/coverage_test/call_package.ipynb @@ -7,6 +7,7 @@ "outputs": [], "source": [ "import package\n", + "\n", "package.func()" ] } diff --git a/tests/raw_files/different_outputs.ipynb b/tests/raw_files/different_outputs.ipynb index c95ca43..ea924bc 100644 --- a/tests/raw_files/different_outputs.ipynb +++ b/tests/raw_files/different_outputs.ipynb @@ -20,6 +20,7 @@ "source": [ "# code cell, no output\n", "import sys\n", + "\n", "from IPython import display" ] }, @@ -38,7 +39,7 @@ ], "source": [ "# code cell + stdout\n", - "print('hallo')" + "print(\"hallo\")" ] }, { @@ -57,8 +58,8 @@ ], "source": [ "# code cell + stdout + stdout\n", - "print('hallo1')\n", - "print('hallo2')" + "print(\"hallo1\")\n", + "print(\"hallo2\")" ] }, { @@ -76,7 +77,7 @@ ], "source": [ "# code cell + stderr\n", - "print('hallo', file=sys.stderr)" + "print(\"hallo\", file=sys.stderr)" ] }, { @@ -101,8 +102,8 @@ ], "source": [ "# code cell + stderr + stdout\n", - "print('hallo1', file=sys.stderr)\n", - "print('hallo2')" + "print(\"hallo1\", file=sys.stderr)\n", + "print(\"hallo2\")" ] }, { @@ -126,7 +127,7 @@ ], "source": [ "# code cell + latex\n", - "display.Latex('\\\\textit{hallo}')" + "display.Latex(\"\\\\textit{hallo}\")" ] }, { @@ -194,7 +195,17 @@ ], "source": [ "# code cell + json\n", - "display.JSON({'a': [1, 2, 3, 4,], 'b': {'inner1': 'helloworld', 'inner2': 'foobar'}})" + "display.JSON(\n", + " {\n", + " \"a\": [\n", + " 1,\n", + " 2,\n", + " 3,\n", + " 4,\n", + " ],\n", + " \"b\": {\"inner1\": \"helloworld\", \"inner2\": \"foobar\"},\n", + " }\n", + ")" ] }, { @@ -220,7 +231,7 @@ ], "source": [ "# code cell + markdown\n", - "display.Markdown('## Header\\n\\n- bullet')" + "display.Markdown(\"## Header\\n\\n- bullet\")" ] }, { @@ -300,7 +311,7 @@ ], "source": [ "# code cell + png\n", - "display.Image(filename='128x128.png', width=200, unconfined=True)" + "display.Image(filename=\"128x128.png\", width=200, unconfined=True)" ] }, { @@ -327,7 +338,7 @@ ], "source": [ "# code cell + jpg\n", - "display.Image(filename='128x128.jpg', width=200, unconfined=True)" + "display.Image(filename=\"128x128.jpg\", width=200, unconfined=True)" ] }, { @@ -381,10 +392,10 @@ } ], "source": [ - "display.display(display.Image(filename='128x128.png', width=200, unconfined=False))\n", - "print('hallo1', file=sys.stderr)\n", - "print('hallo2')\n", - "display.Image(filename='128x128.jpg', width=200, unconfined=True)" + "display.display(display.Image(filename=\"128x128.png\", width=200, unconfined=False))\n", + "print(\"hallo1\", file=sys.stderr)\n", + "print(\"hallo2\")\n", + "display.Image(filename=\"128x128.jpg\", width=200, unconfined=True)" ] }, { @@ -417,9 +428,13 @@ } ], "source": [ - "print('before exception')\n", + "print(\"before exception\")\n", + "\n", + "\n", "def func(b):\n", - " raise ValueError('there was an error')\n", + " raise ValueError(\"there was an error\")\n", + "\n", + "\n", "for i in range(10):\n", " func(i)" ] diff --git a/tests/raw_files/different_outputs_altered.ipynb b/tests/raw_files/different_outputs_altered.ipynb index eb3e17f..2197093 100644 --- a/tests/raw_files/different_outputs_altered.ipynb +++ b/tests/raw_files/different_outputs_altered.ipynb @@ -20,6 +20,7 @@ "source": [ "# code cell, no output\n", "import sys\n", + "\n", "from IPython import display" ] }, @@ -39,7 +40,7 @@ ], "source": [ "# code cell + stdout\n", - "print('hallo')" + "print(\"hallo\")" ] }, { @@ -59,8 +60,8 @@ ], "source": [ "# code cell + stdout + stdout\n", - "print('hallo1')\n", - "print('hallo2')" + "print(\"hallo1\")\n", + "print(\"hallo2\")" ] }, { @@ -78,7 +79,7 @@ ], "source": [ "# code cell + stderr\n", - "print('hallo', file=sys.stderr)" + "print(\"hallo\", file=sys.stderr)" ] }, { @@ -103,8 +104,8 @@ ], "source": [ "# code cell + stderr + stdout\n", - "print('hallo1', file=sys.stderr)\n", - "print('hallo2')" + "print(\"hallo1\", file=sys.stderr)\n", + "print(\"hallo2\")" ] }, { @@ -128,7 +129,7 @@ ], "source": [ "# code cell + latex\n", - "display.Latex('\\\\textit{hallo}')" + "display.Latex(\"\\\\textit{hallo}\")" ] }, { @@ -191,7 +192,17 @@ ], "source": [ "# code cell + json\n", - "display.JSON({'a': [1, 2, 3, 4,], 'b': {'inner1': 'helloworld', 'inner2': 'foobar'}})" + "display.JSON(\n", + " {\n", + " \"a\": [\n", + " 1,\n", + " 2,\n", + " 3,\n", + " 4,\n", + " ],\n", + " \"b\": {\"inner1\": \"helloworld\", \"inner2\": \"foobar\"},\n", + " }\n", + ")" ] }, { @@ -218,7 +229,7 @@ ], "source": [ "# code cell + markdown\n", - "display.Markdown('## Header\\n\\n- bullet')" + "display.Markdown(\"## Header\\n\\n- bullet\")" ] }, { @@ -298,7 +309,7 @@ ], "source": [ "# code cell + png\n", - "display.Image(filename='128x128_altered.png', width=200, unconfined=True)" + "display.Image(filename=\"128x128_altered.png\", width=200, unconfined=True)" ] }, { @@ -325,7 +336,7 @@ ], "source": [ "# code cell + jpg\n", - "display.Image(filename='128x128_altered.jpg', width=200, unconfined=True)" + "display.Image(filename=\"128x128_altered.jpg\", width=200, unconfined=True)" ] }, { @@ -379,10 +390,10 @@ } ], "source": [ - "display.display(display.Image(filename='128x128.png', width=200, unconfined=False))\n", - "print('hallo1', file=sys.stderr)\n", - "print('hallo2')\n", - "display.Image(filename='128x128.jpg', width=200, unconfined=True)" + "display.display(display.Image(filename=\"128x128.png\", width=200, unconfined=False))\n", + "print(\"hallo1\", file=sys.stderr)\n", + "print(\"hallo2\")\n", + "display.Image(filename=\"128x128.jpg\", width=200, unconfined=True)" ] }, { @@ -411,9 +422,13 @@ } ], "source": [ - "print('before exception')\n", + "print(\"before exception\")\n", + "\n", + "\n", "def func(b):\n", - " raise ValueError('there was an error')\n", + " raise ValueError(\"there was an error\")\n", + "\n", + "\n", "for i in range(10):\n", " func(i)" ] diff --git a/tests/raw_files/different_outputs_with_metadata.ipynb b/tests/raw_files/different_outputs_with_metadata.ipynb index 31041dc..82a731e 100644 --- a/tests/raw_files/different_outputs_with_metadata.ipynb +++ b/tests/raw_files/different_outputs_with_metadata.ipynb @@ -20,6 +20,7 @@ "source": [ "# code cell, no output\n", "import sys\n", + "\n", "from IPython import display" ] }, @@ -38,7 +39,7 @@ ], "source": [ "# code cell + stdout\n", - "print('hallo')" + "print(\"hallo\")" ] }, { @@ -57,8 +58,8 @@ ], "source": [ "# code cell + stdout + stdout\n", - "print('hallo1')\n", - "print('hallo2')" + "print(\"hallo1\")\n", + "print(\"hallo2\")" ] }, { @@ -76,7 +77,7 @@ ], "source": [ "# code cell + stderr\n", - "print('hallo', file=sys.stderr)" + "print(\"hallo\", file=sys.stderr)" ] }, { @@ -101,8 +102,8 @@ ], "source": [ "# code cell + stderr + stdout\n", - "print('hallo1', file=sys.stderr)\n", - "print('hallo2')" + "print(\"hallo1\", file=sys.stderr)\n", + "print(\"hallo2\")" ] }, { @@ -126,7 +127,7 @@ ], "source": [ "# code cell + latex\n", - "display.Latex('\\\\textit{hallo}')" + "display.Latex(\"\\\\textit{hallo}\")" ] }, { @@ -200,7 +201,17 @@ ], "source": [ "# code cell + json\n", - "display.JSON({'a': [1, 2, 3, 4,], 'b': {'inner1': 'helloworld', 'inner2': 'foobar'}})" + "display.JSON(\n", + " {\n", + " \"a\": [\n", + " 1,\n", + " 2,\n", + " 3,\n", + " 4,\n", + " ],\n", + " \"b\": {\"inner1\": \"helloworld\", \"inner2\": \"foobar\"},\n", + " }\n", + ")" ] }, { @@ -226,7 +237,7 @@ ], "source": [ "# code cell + markdown\n", - "display.Markdown('## Header\\n\\n- bullet')" + "display.Markdown(\"## Header\\n\\n- bullet\")" ] }, { @@ -312,7 +323,7 @@ ], "source": [ "# code cell + png\n", - "display.Image(filename='128x128.png', width=200, unconfined=True)" + "display.Image(filename=\"128x128.png\", width=200, unconfined=True)" ] }, { @@ -339,7 +350,7 @@ ], "source": [ "# code cell + jpg\n", - "display.Image(filename='128x128.jpg', width=200, unconfined=True)" + "display.Image(filename=\"128x128.jpg\", width=200, unconfined=True)" ] }, { @@ -393,10 +404,10 @@ } ], "source": [ - "display.display(display.Image(filename='128x128.png', width=200, unconfined=False))\n", - "print('hallo1', file=sys.stderr)\n", - "print('hallo2')\n", - "display.Image(filename='128x128.jpg', width=200, unconfined=True)" + "display.display(display.Image(filename=\"128x128.png\", width=200, unconfined=False))\n", + "print(\"hallo1\", file=sys.stderr)\n", + "print(\"hallo2\")\n", + "display.Image(filename=\"128x128.jpg\", width=200, unconfined=True)" ] }, { @@ -429,9 +440,13 @@ } ], "source": [ - "print('before exception')\n", + "print(\"before exception\")\n", + "\n", + "\n", "def func(b):\n", - " raise ValueError('there was an error')\n", + " raise ValueError(\"there was an error\")\n", + "\n", + "\n", "for i in range(10):\n", " func(i)" ] diff --git a/tests/raw_files/images-rearranged.ipynb b/tests/raw_files/images-rearranged.ipynb index 9ade6f4..f88a41c 100644 --- a/tests/raw_files/images-rearranged.ipynb +++ b/tests/raw_files/images-rearranged.ipynb @@ -19,6 +19,7 @@ ], "source": [ "from IPython.display import Image\n", + "\n", "Image(filename=\"128x128.png\")" ] }, @@ -30,12 +31,12 @@ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAAeFBMVEX///8AAAD5+fn8/PzMzMz29vYGBgYSEhLk5OTDw8M8PDzz8/PJycmWlpY5OTkYGBjb29vS0tIkJCRLS0vq6upsbGwtLS2urq4eHh7Y2Ni0tLRmZmbt7e0PDw+KiopgYGCBgYF4eHhXV1eTk5NFRUWfn5+xsbF7e3t2O+vnAAAHeUlEQVR4nO1b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GOa2LV33oSrfoOUqef5UU7vcOBsdtMXZshMLm9e7BGYvFL0Qupl2fK7ZYue0WeJvRk0kp32WpP+ZN3d/PSywz1Yp/ywaQ13MDsqUMEQfvUeTQXfZc6RXpt8ZWMwwh6DMJO+jvhU491tHcT2i8KT/dgzY3hDUCMg+3b2vPlkeu50dgyW3KEVPYMbwDCT+yBtEzEsLbzE7+54F8w7gPDGwCb+kSm0dgbsypyKcwp8+0iHxreAFo8HefX/nsqF9u/PXrldRr72fgVLcJUeFNTIWcGz/8OwgWLx6QtU0ubSYSET/T1w9Qsln0S+hr8qUkkzkDGcfFGRMvJ5jso8ATIuLOwEdiHidyiFcVjub/5DiCQl3Reuw3u1//XbAYJuTvye/gpJVzY+MP/E/8BdLhfZ8sBkDsAAAAASUVORK5CYII=\n", - "text/plain": [ + "text/html": [ "" ], - "text/html": [ - "" - ] + "text/plain": [ + "" + ] }, "execution_count": 7, "metadata": {}, @@ -44,6 +45,7 @@ ], "source": [ "from IPython.display import Image\n", + "\n", "Image(filename=\"128x128_altered.png\")" ] }, @@ -76,10 +78,12 @@ { "data": { "image/jpeg": "/9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2ODApLCBxdWFsaXR5ID0gOTAK/9sAQwADAgIDAgIDAwMDBAMDBAUIBQUEBAUKBwcGCAwKDAwLCgsLDQ4SEA0OEQ4LCxAWEBETFBUVFQwPFxgWFBgSFBUU/9sAQwEDBAQFBAUJBQUJFA0LDRQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAgACAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5Ok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": [ + "" + ], "text/plain": [ "" - ], - "text/html": [""] + ] }, "execution_count": 8, "metadata": {}, @@ -105,12 +109,12 @@ "source": [] }, { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } ], "metadata": { "hide_input": false, diff --git a/tests/raw_files/images.ipynb b/tests/raw_files/images.ipynb index 6e4d9fc..8d50c01 100644 --- a/tests/raw_files/images.ipynb +++ b/tests/raw_files/images.ipynb @@ -19,6 +19,7 @@ ], "source": [ "from IPython.display import Image\n", + "\n", "Image(filename=\"128x128.png\")" ] }, @@ -41,6 +42,7 @@ ], "source": [ "from IPython.display import Image\n", + "\n", "Image(filename=\"128x128_altered.png\")" ] }, diff --git a/tests/raw_files/poorly_formatted_code.ipynb b/tests/raw_files/poorly_formatted_code.ipynb index 8bd65e3..2b75574 100644 --- a/tests/raw_files/poorly_formatted_code.ipynb +++ b/tests/raw_files/poorly_formatted_code.ipynb @@ -8,10 +8,7 @@ "source": [ "#!/usr/bin/env python3\n", "import asyncio\n", - "import sys, os\n", - "\n", - "from black import assert_equivalent, \\\n", - " assert_stable" + "import os" ] }, { @@ -20,11 +17,17 @@ "metadata": {}, "outputs": [], "source": [ - "def very_bad_function(template: str, *variables, file: os.PathLike, engine: str, header: bool = True, debug: bool = False):\n", + "def very_bad_function(\n", + " template: str,\n", + " *variables,\n", + " file: os.PathLike,\n", + " engine: str,\n", + " header: bool = True,\n", + " debug: bool = False,\n", + "):\n", " \"\"\"Applies `variables` to the `template` and writes to `file`.\"\"\"\n", - " with open(file, 'w') as f:\n", - " a = (\"sadsad\"\n", - " \"sadasdas\")" + " with open(file, \"w\") as f:\n", + " a = \"sadsadsadasdas\"" ] }, { @@ -34,14 +37,18 @@ "outputs": [], "source": [ "def func_no_args():\n", - " a; b; c\n", - " if True: raise RuntimeError\n", - " if False: ...\n", - " for i in range(10):\n", - " print(i)\n", - " continue\n", - " exec(\"new-style exec\", {}, {})\n", - " return None" + " a\n", + " b\n", + " c\n", + " if True:\n", + " raise RuntimeError\n", + " if False:\n", + " ...\n", + " for i in range(10):\n", + " print(i)\n", + " continue\n", + " exec(\"new-style exec\", {}, {})\n", + " return None" ] }, { @@ -51,10 +58,10 @@ "outputs": [], "source": [ "async def coroutine(arg, exec=False):\n", - " \"Single-line docstring. Multiline is harder to reformat.\"\n", - " async with some_connection() as conn:\n", - " await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)\n", - " await asyncio.sleep(1)" + " \"Single-line docstring. Multiline is harder to reformat.\"\n", + " async with some_connection() as conn:\n", + " await conn.do_what_i_mean(\"SELECT bobby, tables FROM xkcd\", timeout=2)\n", + " await asyncio.sleep(1)" ] }, { diff --git a/tests/test_nb_regression.py b/tests/test_nb_regression.py index 36bdc0e..1f3c6b9 100644 --- a/tests/test_nb_regression.py +++ b/tests/test_nb_regression.py @@ -1,4 +1,5 @@ """Tests for ``NBRegressionFixture``.""" + import os import pytest diff --git a/tests/test_notebook.py b/tests/test_notebook.py index cdd40b8..92ad50e 100644 --- a/tests/test_notebook.py +++ b/tests/test_notebook.py @@ -1,4 +1,5 @@ """Tests for pytest_notebook.notebook.""" + from pytest_notebook.notebook import ( META_KEY, MetadataConfig, diff --git a/tests/test_plugin_collector.py b/tests/test_plugin_collector.py index 2d52eb8..32acb1b 100644 --- a/tests/test_plugin_collector.py +++ b/tests/test_plugin_collector.py @@ -1,4 +1,5 @@ """Test the plugin collection and direct invocation of notebooks.""" + import os PATH = os.path.dirname(os.path.realpath(__file__)) diff --git a/tests/test_plugin_fixture.py b/tests/test_plugin_fixture.py index c98c927..6aca521 100644 --- a/tests/test_plugin_fixture.py +++ b/tests/test_plugin_fixture.py @@ -1,4 +1,5 @@ """Test the ``nb_regression`` plugin fixture.""" + import os import attr diff --git a/tests/test_postprocessors/test_beautifulsoup.py b/tests/test_postprocessors/test_beautifulsoup.py index eda067e..0203ee6 100644 --- a/tests/test_postprocessors/test_beautifulsoup.py +++ b/tests/test_postprocessors/test_beautifulsoup.py @@ -1,4 +1,5 @@ """Tests for beautifulsoup post-processor.""" + from pytest_notebook.notebook import create_notebook, mapping_to_dict, prepare_cell from pytest_notebook.post_processors import beautifulsoup diff --git a/tests/test_postprocessors/test_blacken_code.py b/tests/test_postprocessors/test_blacken_code.py index 3c8a826..3fcabb0 100644 --- a/tests/test_postprocessors/test_blacken_code.py +++ b/tests/test_postprocessors/test_blacken_code.py @@ -1,4 +1,5 @@ """Tests for blacken_code post-processor.""" + import textwrap from pytest_notebook.notebook import create_notebook, mapping_to_dict, prepare_cell