diff options
Diffstat (limited to 'nbs/test.ipynb')
| -rw-r--r-- | nbs/test.ipynb | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/nbs/test.ipynb b/nbs/test.ipynb index 5f8aafb..c6430bb 100644 --- a/nbs/test.ipynb +++ b/nbs/test.ipynb @@ -30,8 +30,9 @@ "outputs": [], "source": [ "#| export\n", - "import ast,copy,contextlib,inspect,os,operator,reprlib,textwrap,traceback\n", - "from typing import Any,Callable,Generator\n", + "import ast,contextlib,inspect,os,operator,reprlib,traceback\n", + "from collections.abc import Callable,Generator\n", + "from typing import Any\n", "from dataclasses import dataclass" ] }, @@ -96,6 +97,7 @@ " 'f_back',\n", " 'f_builtins',\n", " 'f_code',\n", + " 'f_generator',\n", " 'f_globals',\n", " 'f_lasti',\n", " 'f_lineno',\n", @@ -130,7 +132,7 @@ "outputs": [], "source": [ "def f(x,y,z,a=1):\n", - " return inspect.getouterframes(inspect.currentframe())[1]\n" + " return inspect.getouterframes(inspect.currentframe())[1]" ] }, { @@ -196,7 +198,7 @@ "id": "cf730643", "metadata": {}, "source": [ - "From this, we can see `code_context` has the first line of context of where we're executing `f`. Furthermore, note `positions` has all the information around we're extract out only our call to `f` from this block of code." + "From this, we can see `code_context` has the first line of context of where we're executing `f`. Furthermore, note `positions` has all the information around extracting out only our call to `f` from this block of code." ] }, { @@ -616,7 +618,7 @@ "id": "a25dcdf0", "metadata": {}, "source": [ - "### Raises" + "### raises" ] }, { @@ -682,7 +684,15 @@ "id": "765265ca", "metadata": {}, "source": [ - "### Primitives (expect, expect_fail)" + "### expect/expect_fail" + ] + }, + { + "cell_type": "markdown", + "id": "bb55fd30-1396-4cf0-8aff-495acfb1c9ff", + "metadata": {}, + "source": [ + "`expect` is a basic primitive for creating *other assertion helpers*. It takes two arguments and a callable and checks whether calling the callable with the two arguments yields `True`. If it doesn't, it prints a friendly error message." ] }, { @@ -710,15 +720,8 @@ " lines = [f'{a_src} {negstr} {b_src}']\n", " if len(args_src) > 0 and a_repr != args_src[0]: lines.append(f' where {args_src[0]} = {a_repr}')\n", " if len(args_src) > 1 and b_repr != args_src[1]: lines.append(f' where {args_src[1]} = {b_repr}')\n", - " assert cmp(a, b), \"\\n\".join(lines)" - ] - }, - { - "cell_type": "markdown", - "id": "b583f813", - "metadata": {}, - "source": [ - "`expect` is a basic primitive for creating other assertion helpers. It takes two arguments and a callable and checks whether calling the callable with the two arguments yields `True`. If it doesn't, it prints a friendly error message." + " if not cmp(a, b):\n", + " raise AssertionError(\"\\n\".join(lines)).with_traceback(None)" ] }, { @@ -943,7 +946,7 @@ "id": "4ca8f337", "metadata": {}, "source": [ - "### Higher Level Assertions" + "### equal/nequal" ] }, { @@ -1015,6 +1018,14 @@ ] }, { + "cell_type": "markdown", + "id": "dc43ed6e-2fce-40b6-bb18-bf0ab51286ed", + "metadata": {}, + "source": [ + "### is_true/is_false" + ] + }, + { "cell_type": "code", "execution_count": null, "id": "9523b71e", @@ -1162,7 +1173,13 @@ ] } ], - "metadata": {}, + "metadata": { + "kernelspec": { + "display_name": "python3", + "language": "python", + "name": "python3" + } + }, "nbformat": 4, "nbformat_minor": 5 } |