python: workaround different help() output in Python 3.12

Python 3.12 introduced some subtle changes in the way doc strings are
displayed by help().  This was causing spurious errors in the
following test.

* tests/python/formulas.ipynb: Use print(x.__doc__) instead of
help(x).
This commit is contained in:
Alexandre Duret-Lutz 2024-05-03 16:32:16 +02:00
parent e6362b785b
commit c5c3e905ae

View file

@ -10,7 +10,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -27,7 +27,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -39,7 +39,7 @@
"spot.formula(\"p1 U (p2 R (p3 & !p4))\")" "spot.formula(\"p1 U (p2 R (p3 & !p4))\")"
] ]
}, },
"execution_count": 2, "execution_count": 11,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -51,7 +51,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -63,7 +63,7 @@
"spot.formula(\"{a;first_match({b[*];c[+]}[:*3..5];b)}<>-> (c & GFb)\")" "spot.formula(\"{a;first_match({b[*];c[+]}[:*3..5];b)}<>-> (c & GFb)\")"
] ]
}, },
"execution_count": 3, "execution_count": 12,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -81,7 +81,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 13,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -93,7 +93,7 @@
"spot.formula(\"c & (a | b)\")" "spot.formula(\"c & (a | b)\")"
] ]
}, },
"execution_count": 4, "execution_count": 13,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -111,7 +111,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 14,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -123,7 +123,7 @@
"spot.formula(\"c & (a | b)\")" "spot.formula(\"c & (a | b)\")"
] ]
}, },
"execution_count": 5, "execution_count": 14,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -142,7 +142,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 15,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -151,7 +151,7 @@
"'p1 U (p2 R (p3 & !p4))'" "'p1 U (p2 R (p3 & !p4))'"
] ]
}, },
"execution_count": 6, "execution_count": 15,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -169,7 +169,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 16,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -201,7 +201,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 17,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -231,64 +231,63 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"The specifiers that can be used with `format` are documented as follows:" "The specifiers that can be used with `format` are documented as follows.\n",
"(Note: As this document is part of our test-suite we have to use `print(x.__doc__)` instead of `help(x)` to work around some formating changes introduced in Python 3.12's `help()`.)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 18,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Help on function __format__ in module spot:\n", "Format the formula according to `spec`.\n",
"\n", "\n",
"__format__(self, spec)\n", " Parameters\n",
" Format the formula according to `spec`.\n", " ----------\n",
" \n", " spec : str, optional\n",
" Parameters\n", " a list of letters that specify how the formula\n",
" ----------\n", " should be formatted.\n",
" spec : str, optional\n", "\n",
" a list of letters that specify how the formula\n", " Supported specifiers\n",
" should be formatted.\n", " --------------------\n",
" \n", "\n",
" Supported specifiers\n", " - 'f': use Spot's syntax (default)\n",
" --------------------\n", " - '8': use Spot's syntax in UTF-8 mode\n",
" \n", " - 's': use Spin's syntax\n",
" - 'f': use Spot's syntax (default)\n", " - 'l': use LBT's syntax\n",
" - '8': use Spot's syntax in UTF-8 mode\n", " - 'w': use Wring's syntax\n",
" - 's': use Spin's syntax\n", " - 'x': use LaTeX output\n",
" - 'l': use LBT's syntax\n", " - 'X': use self-contained LaTeX output\n",
" - 'w': use Wring's syntax\n", " - 'j': use self-contained LaTeX output, adjusted for MathJax\n",
" - 'x': use LaTeX output\n", "\n",
" - 'X': use self-contained LaTeX output\n", " Add some of those letters for additional options:\n",
" - 'j': use self-contained LaTeX output, adjusted for MathJax\n", "\n",
" \n", " - 'p': use full parentheses\n",
" Add some of those letters for additional options:\n", " - 'c': escape the formula for CSV output (this will\n",
" \n", " enclose the formula in double quotes, and escape\n",
" - 'p': use full parentheses\n", " any included double quotes)\n",
" - 'c': escape the formula for CSV output (this will\n", " - 'h': escape the formula for HTML output\n",
" enclose the formula in double quotes, and escape\n", " - 'd': escape double quotes and backslash,\n",
" any included double quotes)\n", " for use in C-strings (the outermost double\n",
" - 'h': escape the formula for HTML output\n", " quotes are *not* added)\n",
" - 'd': escape double quotes and backslash,\n", " - 'q': quote and escape for shell output, using single\n",
" for use in C-strings (the outermost double\n", " quotes or double quotes depending on the contents.\n",
" quotes are *not* added)\n", " - '[...]': rewrite away all the operators specified in brackets,\n",
" - 'q': quote and escape for shell output, using single\n", " using spot.unabbreviate().\n",
" quotes or double quotes depending on the contents.\n", "\n",
" - '[...]': rewrite away all the operators specified in brackets,\n", " - ':spec': pass the remaining specification to the\n",
" using spot.unabbreviate().\n", " formating function for strings.\n",
" \n", "\n",
" - ':spec': pass the remaining specification to the\n", " \n"
" formating function for strings.\n",
"\n"
] ]
} }
], ],
"source": [ "source": [
"help(spot.formula.__format__)" "print(spot.formula.__format__.__doc__)"
] ]
}, },
{ {
@ -300,7 +299,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 19,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -309,7 +308,7 @@
"True" "True"
] ]
}, },
"execution_count": 10, "execution_count": 19,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -320,7 +319,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 20,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -329,7 +328,7 @@
"False" "False"
] ]
}, },
"execution_count": 11, "execution_count": 20,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -347,7 +346,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 21,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -356,7 +355,7 @@
"True" "True"
] ]
}, },
"execution_count": 12, "execution_count": 21,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -367,7 +366,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 22,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -376,7 +375,7 @@
"False" "False"
] ]
}, },
"execution_count": 13, "execution_count": 22,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -387,7 +386,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 23,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -396,7 +395,7 @@
"True" "True"
] ]
}, },
"execution_count": 14, "execution_count": 23,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -414,7 +413,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 24,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -426,7 +425,7 @@
"spot.formula(\"\\\"a > b\\\" & \\\"proc[2]@init\\\" & GF_foo_\")" "spot.formula(\"\\\"a > b\\\" & \\\"proc[2]@init\\\" & GF_foo_\")"
] ]
}, },
"execution_count": 15, "execution_count": 24,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -437,7 +436,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 25,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -449,7 +448,7 @@
"spot.formula(\"a & b & GFc\")" "spot.formula(\"a & b & GFc\")"
] ]
}, },
"execution_count": 16, "execution_count": 25,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -460,7 +459,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 26,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -472,7 +471,7 @@
"spot.formula(\"p0 & p1 & GFp2\")" "spot.formula(\"p0 & p1 & GFp2\")"
] ]
}, },
"execution_count": 17, "execution_count": 26,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -490,7 +489,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": 27,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -711,7 +710,7 @@
"<spot.jupyter.SVG object>" "<spot.jupyter.SVG object>"
] ]
}, },
"execution_count": 18, "execution_count": 27,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -729,7 +728,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 28,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -765,7 +764,7 @@
"<spot.jupyter.SVG object>" "<spot.jupyter.SVG object>"
] ]
}, },
"execution_count": 19, "execution_count": 28,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -776,7 +775,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": 29,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -785,7 +784,7 @@
"'recurrence'" "'recurrence'"
] ]
}, },
"execution_count": 20, "execution_count": 29,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -796,7 +795,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": 30,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -808,7 +807,7 @@
"spot.formula(\"F(a & X(!a & b))\")" "spot.formula(\"F(a & X(!a & b))\")"
] ]
}, },
"execution_count": 21, "execution_count": 30,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -826,7 +825,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 22, "execution_count": 31,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -838,7 +837,7 @@
"spot.formula(\"F(a & ((a & (a U (!a & b)) & ((!b U !a) | (b U !a))) | (!a & (!a U (a & !a & b)) & ((!b U a) | (b U a))) | (b & (b U (!a & b & !b)) & ((!a U !b) | (a U !b))) | (!b & (!b U (!a & b)) & ((!a U b) | (a U b))) | (!a & b & (G!a | Ga) & (G!b | Gb))))\")" "spot.formula(\"F(a & ((a & (a U (!a & b)) & ((!b U !a) | (b U !a))) | (!a & (!a U (a & !a & b)) & ((!b U a) | (b U a))) | (b & (b U (!a & b & !b)) & ((!a U !b) | (a U !b))) | (!b & (!b U (!a & b)) & ((!a U b) | (a U b))) | (!a & b & (G!a | Ga) & (G!b | Gb))))\")"
] ]
}, },
"execution_count": 22, "execution_count": 31,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -856,7 +855,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 23, "execution_count": 32,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -868,7 +867,7 @@
"spot.formula(\"(0 R !(a <-> b)) -> (1 U (a <-> b))\")" "spot.formula(\"(0 R !(a <-> b)) -> (1 U (a <-> b))\")"
] ]
}, },
"execution_count": 23, "execution_count": 32,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -880,7 +879,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 24, "execution_count": 33,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -892,7 +891,7 @@
"spot.formula(\"(1 U ((a & b) | (!a & !b))) | !(0 R ((!a & b) | (a & !b)))\")" "spot.formula(\"(1 U ((a & b) | (!a & !b))) | !(0 R ((!a & b) | (a & !b)))\")"
] ]
}, },
"execution_count": 24, "execution_count": 33,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -910,7 +909,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 25, "execution_count": 34,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -946,7 +945,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 26, "execution_count": 35,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -986,7 +985,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 27, "execution_count": 36,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {