Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 23, 2024
1 parent feb7697 commit fa84874
Show file tree
Hide file tree
Showing 26 changed files with 176 additions and 103 deletions.
1 change: 1 addition & 0 deletions pytest_notebook/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""A pytest plugin for testing Jupyter Notebooks."""

__version__ = "0.10.0"
1 change: 1 addition & 0 deletions pytest_notebook/diffing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Diffing of notebooks."""

import copy
import operator
import re
Expand Down
5 changes: 2 additions & 3 deletions pytest_notebook/example_nbs/coverage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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__)"
]
}
],
Expand Down
8 changes: 3 additions & 5 deletions pytest_notebook/example_nbs/example1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from IPython import display"
]
"source": []
},
{
"cell_type": "code",
Expand All @@ -31,8 +29,8 @@
}
],
"source": [
"print('hallo1')\n",
"print('hallo2')"
"print(\"hallo1\")\n",
"print(\"hallo2\")"
]
}
],
Expand Down
8 changes: 3 additions & 5 deletions pytest_notebook/example_nbs/example1_pass.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from IPython import display"
]
"source": []
},
{
"cell_type": "code",
Expand All @@ -31,8 +29,8 @@
}
],
"source": [
"print('hallo1')\n",
"print('hallo2')"
"print(\"hallo1\")\n",
"print(\"hallo2\")"
]
}
],
Expand Down
16 changes: 10 additions & 6 deletions pytest_notebook/example_nbs/example2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
}
],
"source": [
"print('hallo1')\n",
"print('hallo2')"
"print(\"hallo1\")\n",
"print(\"hallo2\")"
]
},
{
Expand Down Expand Up @@ -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)"
]
},
{
Expand All @@ -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)"
]
},
{
Expand Down Expand Up @@ -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)"
]
Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/execution.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Execution of notebooks."""

from contextlib import nullcontext
import copy
import json
Expand Down
3 changes: 2 additions & 1 deletion pytest_notebook/ipy_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/nb_regression.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Jupyter Notebook Regression Test Class."""

import copy
import logging
import os
Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/notebook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for working with notebook."""

import copy
from functools import lru_cache

Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- https://docs.pytest.org/en/latest/_modules/_pytest/hookspec.html
"""

import os
import shlex

Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/post_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
All functions should take (notebook, resources) as input,
and output a (new notebook, resources).
"""

import copy
import functools
import logging
Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions."""

import os
import textwrap
import warnings
Expand Down
1 change: 1 addition & 0 deletions tests/raw_files/coverage_test/call_package.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"outputs": [],
"source": [
"import package\n",
"\n",
"package.func()"
]
}
Expand Down
49 changes: 32 additions & 17 deletions tests/raw_files/different_outputs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"source": [
"# code cell, no output\n",
"import sys\n",
"\n",
"from IPython import display"
]
},
Expand All @@ -38,7 +39,7 @@
],
"source": [
"# code cell + stdout\n",
"print('hallo')"
"print(\"hallo\")"
]
},
{
Expand All @@ -57,8 +58,8 @@
],
"source": [
"# code cell + stdout + stdout\n",
"print('hallo1')\n",
"print('hallo2')"
"print(\"hallo1\")\n",
"print(\"hallo2\")"
]
},
{
Expand All @@ -76,7 +77,7 @@
],
"source": [
"# code cell + stderr\n",
"print('hallo', file=sys.stderr)"
"print(\"hallo\", file=sys.stderr)"
]
},
{
Expand All @@ -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\")"
]
},
{
Expand All @@ -126,7 +127,7 @@
],
"source": [
"# code cell + latex\n",
"display.Latex('\\\\textit{hallo}')"
"display.Latex(\"\\\\textit{hallo}\")"
]
},
{
Expand Down Expand Up @@ -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",
")"
]
},
{
Expand All @@ -220,7 +231,7 @@
],
"source": [
"# code cell + markdown\n",
"display.Markdown('## Header\\n\\n- bullet')"
"display.Markdown(\"## Header\\n\\n- bullet\")"
]
},
{
Expand Down Expand Up @@ -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)"
]
},
{
Expand All @@ -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)"
]
},
{
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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)"
]
Expand Down
Loading

0 comments on commit fa84874

Please sign in to comment.