From 7e12d1607ca5832b44af12abdba2a94f0acd9f99 Mon Sep 17 00:00:00 2001 From: "Jose D. Gomez R" Date: Mon, 23 Oct 2023 10:49:25 +0200 Subject: [PATCH] Aligning python signature with os-autoinst limitations Python test modules do not support any other argument but `self`. This limitation is enforced now in os-autoinst and now documented in the docs. --- docs/WritingTests.asciidoc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/WritingTests.asciidoc b/docs/WritingTests.asciidoc index 519d07bfb2e6..99b8debae3ea 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(self): # 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(*_): +def run(self): 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(self): perl.require('x11utils') # Start vncviewer - notice the named arguments passed as positional arguments @@ -235,10 +235,12 @@ 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. +Additionally, Python tests do not support `run_args`. An error will be present +when a python test detects the presence of `run_args` on schedule. + +This is because of the way `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"] @@ -359,7 +361,7 @@ implementing the interface described above. -------------------------------------------------------------- from testapi import * -def run(*_): +def run(self): assert_screen('openqa-logged-in') assert_and_click('openqa-search') type_string('shutdown.pm')