diff --git a/src/sections/items.tex b/src/sections/items.tex index 264d4fb..b5a13e9 100644 --- a/src/sections/items.tex +++ b/src/sections/items.tex @@ -185,6 +185,7 @@ def dummy_func(param1, param2, param4, param4): \item To get a variable from the global dictionnary : \incode{tm.gd("global\_dict\_key")} \item To set a variable from the global dictionnary : \incode{tm.setgd("global\_dict\_key", value)} \end{itemize} + \item \incode{context\_id}: share a persistent subprocess across \incode{py\_func} items \end{itemize} \end{frame} @@ -205,9 +206,63 @@ end \item To get a variable from the global dictionnary : \incode{tm.gd("global\_dict\_key")} \item To set a variable from the global dictionnary : \incode{tm.setgd("global\_dict\_key", value)} \end{itemize} + \item \incode{context\_id}: share a persistent subprocess across \incode{lua\_func} items \end{itemize} \end{frame} +\begin{frame}[fragile]{\incode{context\_id} — shared persistent subprocess} +\begin{columns} + \column{0.5\textwidth} + \begin{itemize} + \item By default, each \incode{py\_func}/\incode{lua\_func} call spawns its own subprocess + \begin{itemize} + \item module-level state is \textbf{not} preserved between calls + \end{itemize} + \item \incode{context\_id}: items sharing the same id reuse the \textbf{same} persistent subprocess + \begin{itemize} + \item subprocess lives until the end of the test run + \item required for non-JSON-serializable objects (connections, handles\ldots) + \end{itemize} + \item \incode{tm.setgd}/\incode{tm.gd} always work across all items for serializable values + \begin{itemize} + \item non-serializable values (\incode{py\_func} only) are kept locally in the subprocess + \end{itemize} + \end{itemize} + \column{0.5\textwidth} + \begin{minted}[fontsize=\fontsize{6}{7}\selectfont]{yaml} +- py_func: + name: open connection + file: my_script.py + func_name: open_connection + context_id: my_context + expected_result: ok + +- py_func: + name: use connection + file: my_script.py + func_name: use_connection + context_id: my_context + expected_result: open + \end{minted} + \begin{minted}[fontsize=\fontsize{6}{7}\selectfont]{yaml} +- lua_func: + name: produce value + file: my_script.lua + func_name: produce + context_id: my_context + param: + - hello + +- lua_func: + name: consume value + file: my_script.lua + func_name: consume + context_id: my_context + expected_result: hello + \end{minted} +\end{columns} +\end{frame} + \begin{frame}[fragile]{\incode{group} test item} \begin{itemize} \item \incode{steps}: The list of items in the group diff --git a/testium_training.pdf b/testium_training.pdf index 36dd204..5c43894 100644 Binary files a/testium_training.pdf and b/testium_training.pdf differ