From 761066759d63a3e0523c64d0e852b1625ae1a9fc Mon Sep 17 00:00:00 2001 From: "Jose D. Gomez R" Date: Fri, 20 Oct 2023 14:35:25 +0200 Subject: [PATCH] Document `run_args` limitation on Python Modules. Arguments sent from Perl to Python can't be used (due to blessed references not properly translated to Python into usable objects). A note of caution is added to warn against using any argument in the `run` function and updated examples. --- docs/WritingTests.asciidoc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/WritingTests.asciidoc b/docs/WritingTests.asciidoc index 72cd72913370..519d07bfb2e6 100644 --- a/docs/WritingTests.asciidoc +++ b/docs/WritingTests.asciidoc @@ -65,7 +65,7 @@ And here is an example in Python: ------------------------------------------------------------------- from testapi import * -def run(): +def run(*_): # write in this block the code for your test. ------------------------------------------------------------------- @@ -76,7 +76,7 @@ _Please note that the subroutine marked with `*1` are optional._ [source,python] ------------------------------------------------------------------- # Written in type-hinted python to indicate explicitly return types -def run(): -> None +def run(*_): def test_flags(): -> dict # *1 def post_fail_hook(): -> None # *1 def pre_run_hook(): -> None # *1 @@ -222,7 +222,7 @@ from testapi import * # [...] omitted for brevity -def run(): +def run(*_): perl.require('x11utils') # Start vncviewer - notice the named arguments passed as positional arguments @@ -235,6 +235,11 @@ def run(): # [...] omitted for brevity ------------------------------------------------------------------- +Additionally, the `run` method in Python is not able to handle any argument +passed. Due to how `Inline::Python` handles arguments passing between Perl <-> +Python, references to complex Perl objects do not reach python properly and +they can't be used. + === Example Perl test modules [id="testmodule_perl_examples"] @@ -354,7 +359,7 @@ implementing the interface described above. -------------------------------------------------------------- from testapi import * -def run(self): +def run(*_): assert_screen('openqa-logged-in') assert_and_click('openqa-search') type_string('shutdown.pm')