python func validation ok.
This commit is contained in:
@@ -64,6 +64,9 @@ In the example above, the global variable ``$(lfn_activity)``
|
||||
would be created at the end of the item execution. It would contain the resulting
|
||||
value of the funcToBeExecuted python function.
|
||||
|
||||
The ``lua_func`` will always result ``PASS``, except if the called function raises
|
||||
and exception or if the ``expected_result`` attribute is used.
|
||||
|
||||
**Lua Interpreter environment setup**
|
||||
|
||||
Some global variables have an impact on the ``lua_func`` test item behavior:
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
The ``py_func`` test item is used to execute custom python scripts with the given
|
||||
input parameters.
|
||||
|
||||
There are two modes for executing a ``py_func`` item. The class mode and the function mode.
|
||||
There are two modes for executing a ``py_func`` item. The *class* mode and the *function* mode.
|
||||
|
||||
class py_func item
|
||||
class ``py_func`` item
|
||||
-------------------------
|
||||
|
||||
This is the normal way of calling some custom python code.
|
||||
@@ -80,7 +80,8 @@ There is no possibility to access the report features in that mode.
|
||||
|
||||
**Attributes**
|
||||
|
||||
Beside common test items attributes, py_func item has specific attribute, some of which being mandatory.
|
||||
Beside common test items attributes, ``py_func`` item has specific attribute,
|
||||
some of which being mandatory.
|
||||
|
||||
* ``file``: the script file name that contains the function to be executed.
|
||||
Only python script format is supported.
|
||||
@@ -107,6 +108,9 @@ In the example above, the global variable ``$(pfn_function test item)``
|
||||
would be created at the end of the item execution. It would contain the resulting
|
||||
value of the funcToBeExecuted python function.
|
||||
|
||||
The ``py_func`` will always result ``PASS``, except if the called function raises
|
||||
and exception or if the ``expected_result`` attribute is used.
|
||||
|
||||
**Python Interpreter environment setup**
|
||||
|
||||
Some global variables have an impact on the ``py_func`` test item behavior:
|
||||
|
||||
@@ -7,6 +7,7 @@ import libs.testium as tm
|
||||
from interpreter.utils.paths import sys_app_path_lin, sys_app_path_win
|
||||
from interpreter.utils.tum_except import ETUMRuntimeError
|
||||
from interpreter.utils.jrpc import JsonRpcClient
|
||||
from interpreter.utils.paths import testium_path
|
||||
from interpreter.test_items.test_result import TestValue
|
||||
|
||||
function_call_process = None
|
||||
@@ -147,7 +148,7 @@ class LuaFuncExecEngine:
|
||||
)
|
||||
tm.setgd("lua_bin", lua_bin)
|
||||
|
||||
self._lpath = lua_bin
|
||||
self._lbin = lua_bin
|
||||
self._req_handler = request_handler
|
||||
self._process = None
|
||||
self._port = 0
|
||||
@@ -168,7 +169,7 @@ class LuaFuncExecEngine:
|
||||
if self._process is not None:
|
||||
raise ETUMRuntimeError("The function subprocess has already been started.")
|
||||
|
||||
func_proc_path = os.path.join(tm.gd("testium_path"),"lua_func")
|
||||
func_proc_path = os.path.realpath(os.path.join(testium_path(), "..", "lua_func"))
|
||||
|
||||
# POpen config
|
||||
CUST_ENV = {
|
||||
@@ -190,9 +191,10 @@ class LuaFuncExecEngine:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.bind(("localhost", 0))
|
||||
self._port = sock.getsockname()[1]
|
||||
sock.close()
|
||||
|
||||
# POpen params
|
||||
params = [self._lpath, "main.lua", "--timeout", f"{self._timeout}", "--host", "127.0.0.1", "--port", f"{self._port}"]
|
||||
params = [self._lbin, "main.lua", "--timeout", f"{self._timeout}", "--host", "127.0.0.1", "--port", f"{self._port}"]
|
||||
|
||||
if tm.debug_enabled() and tm.gd("debug_rpc", False):
|
||||
params.append("--verbose")
|
||||
@@ -201,10 +203,6 @@ class LuaFuncExecEngine:
|
||||
params, env=env, cwd=func_proc_path
|
||||
)
|
||||
|
||||
# Port was reserved until the sub-process is started. Now released.
|
||||
if sock is not None:
|
||||
sock.close()
|
||||
|
||||
self._rpc = JsonRpcClient("localhost", self._port, req_handler=self._req_handler)
|
||||
if tm.debug_enabled() and tm.gd("debug_rpc", False):
|
||||
self._rpc.dbg_out = sys.stdout
|
||||
|
||||
@@ -1,73 +1,61 @@
|
||||
- let:
|
||||
name: func test constants,
|
||||
values:
|
||||
test parameter: test parameter
|
||||
|
||||
- py_func:
|
||||
name: pass func
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)func.py
|
||||
func_name: assertparam
|
||||
param:
|
||||
- true
|
||||
|
||||
- py_func:
|
||||
name: fail func
|
||||
- lua_func:
|
||||
name: fail lua_func
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: assertparam
|
||||
param:
|
||||
- false
|
||||
|
||||
- py_func:
|
||||
name: fail func with expected result "FAIL"
|
||||
- lua_func:
|
||||
name: fail lua_func with expected result FAIL
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: assertparam
|
||||
param:
|
||||
- false
|
||||
expected_result: FAIL
|
||||
|
||||
- py_func:
|
||||
name: pass func with expected result FAIL
|
||||
- lua_func:
|
||||
name: pass lua_func with expected result FAIL
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: assertparam
|
||||
param:
|
||||
- true
|
||||
expected_result: FAIL
|
||||
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: expected -1
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: echo
|
||||
param:
|
||||
- -1
|
||||
expected_result: -1
|
||||
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: expected eval
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: echo
|
||||
param:
|
||||
- -1
|
||||
expected_result: "354848436 - 354848437"
|
||||
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: expected table
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: echo
|
||||
param:
|
||||
- [-1, a, {toto: tata}]
|
||||
expected_result: "[-1, 'a', {'toto': 'tata'}]"
|
||||
|
||||
- py_func:
|
||||
name: global param func
|
||||
- lua_func:
|
||||
name: global param lua_func
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: checkglobal
|
||||
param:
|
||||
- $(test parameter)
|
||||
@@ -76,50 +64,50 @@
|
||||
name: python2func
|
||||
key: $(test)_PASS
|
||||
values:
|
||||
- py: $(test_path)$(psep)func.py
|
||||
- py: $(test_path)$(psep)lua_func.lua
|
||||
|
||||
- py_func:
|
||||
name: global param func
|
||||
- lua_func:
|
||||
name: global param lua_func
|
||||
key: $(test)_PASS
|
||||
file: $(py)
|
||||
func_name: checkglobal
|
||||
param:
|
||||
- $(test parameter)
|
||||
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: skipped_checkglobal
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: should_not_be_called
|
||||
param:
|
||||
- $(test parameter)
|
||||
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: skipped true
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: checkglobal
|
||||
skipped: true
|
||||
param:
|
||||
- $(test parameter)
|
||||
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: skipped true
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: checkglobal
|
||||
skipped: true
|
||||
param:
|
||||
- $(test parameter)
|
||||
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: skipped 1
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: checkglobal
|
||||
skipped: 1
|
||||
param:
|
||||
- $(test parameter)
|
||||
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: FunctionItem test
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: ValidationTest
|
||||
param:
|
||||
- $(test parameter)
|
||||
@@ -130,54 +118,54 @@
|
||||
- group:
|
||||
name: Function result failure
|
||||
steps:
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: int failure
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)func.py
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: echo
|
||||
param: [-1]
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: float failure
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)func.py
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: echo
|
||||
param: [-1.3]
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: String failure
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)func.py
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: echo
|
||||
param: [ "FAIL" ]
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: Tuple int,str failure
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)func.py
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: tuple_return
|
||||
param: [ -1, "Got a failure" ]
|
||||
- group:
|
||||
name: Functions result success
|
||||
steps:
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: int success
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: echo
|
||||
param: [0]
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: float success
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: echo
|
||||
param: [0.3]
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: String success
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: echo
|
||||
param: [ "Something that is not only strictly FAIL" ]
|
||||
- py_func:
|
||||
- lua_func:
|
||||
name: Tuple int,str success
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)func.py
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: tuple_return
|
||||
param: [ 0, "OK" ]
|
||||
|
||||
@@ -16,6 +16,9 @@ def checkglobal(param):
|
||||
assert param=='test parameter'
|
||||
return 0
|
||||
|
||||
def checkglobal2():
|
||||
return tm.gd("py_func test parameter")
|
||||
|
||||
def should_not_be_called(param):
|
||||
raise
|
||||
|
||||
|
||||
@@ -1,179 +1,191 @@
|
||||
- let:
|
||||
name: py_func test constants,
|
||||
values:
|
||||
py_func test parameter: test parameter
|
||||
|
||||
- lua_func:
|
||||
name: pass lua_func
|
||||
- py_func:
|
||||
name: pass py_func
|
||||
key: $(test)_PASS
|
||||
file: lua_func.lua
|
||||
func_name: func_to_be_executed
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: assertparam
|
||||
param:
|
||||
- true
|
||||
|
||||
- lua_func:
|
||||
name: fail lua_func
|
||||
- py_func:
|
||||
name: fail py_func
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: assertparam
|
||||
param:
|
||||
- false
|
||||
|
||||
- lua_func:
|
||||
name: fail lua_func with expected result FAIL
|
||||
- py_func:
|
||||
name: fail py_func with expected result "FAIL"
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: assertparam
|
||||
param:
|
||||
- false
|
||||
expected_result: FAIL
|
||||
|
||||
- lua_func:
|
||||
name: pass lua_func with expected result FAIL
|
||||
- py_func:
|
||||
name: pass py_func with expected result FAIL
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: assertparam
|
||||
param:
|
||||
- true
|
||||
expected_result: FAIL
|
||||
|
||||
- lua_func:
|
||||
- py_func:
|
||||
name: expected -1
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: echo
|
||||
param:
|
||||
- -1
|
||||
expected_result: -1
|
||||
|
||||
- lua_func:
|
||||
- py_func:
|
||||
name: expected eval
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: echo
|
||||
param:
|
||||
- -1
|
||||
expected_result: "354848436 - 354848437"
|
||||
|
||||
- lua_func:
|
||||
- py_func:
|
||||
name: expected table
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: echo
|
||||
param:
|
||||
- [-1, a, {toto: tata}]
|
||||
expected_result: "[-1, 'a', {'toto': 'tata'}]"
|
||||
|
||||
- lua_func:
|
||||
name: global param lua_func
|
||||
- py_func:
|
||||
name: global param py_func
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: checkglobal
|
||||
param:
|
||||
- $(test parameter)
|
||||
- $(py_func test parameter)
|
||||
|
||||
- let:
|
||||
name: python2func
|
||||
key: $(test)_PASS
|
||||
values:
|
||||
- py: $(test_path)$(psep)lua_func.lua
|
||||
- py: $(test_path)$(psep)py_func.py
|
||||
|
||||
- lua_func:
|
||||
name: global param lua_func
|
||||
- py_func:
|
||||
name: global param py_func 2
|
||||
key: $(test)_PASS
|
||||
file: $(py)
|
||||
func_name: checkglobal2
|
||||
expected_result: $(py_func test parameter)
|
||||
|
||||
|
||||
- py_func:
|
||||
name: global param py_func
|
||||
key: $(test)_PASS
|
||||
file: $(py)
|
||||
func_name: checkglobal
|
||||
param:
|
||||
- $(test parameter)
|
||||
- $(py_func test parameter)
|
||||
|
||||
- lua_func:
|
||||
- py_func:
|
||||
name: skipped_checkglobal
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: should_not_be_called
|
||||
param:
|
||||
- $(test parameter)
|
||||
- $(py_func test parameter)
|
||||
|
||||
- lua_func:
|
||||
- py_func:
|
||||
name: skipped true
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: checkglobal
|
||||
skipped: true
|
||||
param:
|
||||
- $(test parameter)
|
||||
- $(py_func test parameter)
|
||||
|
||||
- lua_func:
|
||||
name: skipped true
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
func_name: checkglobal
|
||||
skipped: true
|
||||
param:
|
||||
- $(test parameter)
|
||||
|
||||
- lua_func:
|
||||
- py_func:
|
||||
name: skipped 1
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: checkglobal
|
||||
skipped: 1
|
||||
param:
|
||||
- $(test parameter)
|
||||
- $(py_func test parameter)
|
||||
|
||||
- lua_func:
|
||||
- py_func:
|
||||
name: FunctionItem test
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: ValidationTest
|
||||
param:
|
||||
- $(test parameter)
|
||||
- $(py_func test parameter)
|
||||
|
||||
- group:
|
||||
name: Function results check
|
||||
steps:
|
||||
- group:
|
||||
name: Function result failure
|
||||
name: Function result 1
|
||||
steps:
|
||||
- lua_func:
|
||||
- py_func:
|
||||
name: int failure
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: echo
|
||||
param: [-1]
|
||||
- lua_func:
|
||||
expected_result: -1
|
||||
- py_func:
|
||||
name: float failure
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: echo
|
||||
param: [-1.3]
|
||||
- lua_func:
|
||||
expected_result: -1.3
|
||||
- py_func:
|
||||
name: String failure
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: echo
|
||||
param: [ "FAIL" ]
|
||||
- lua_func:
|
||||
expected_result: FAIL
|
||||
- py_func:
|
||||
name: Tuple int,str failure
|
||||
key: $(test)_FAIL
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: tuple_return
|
||||
param: [ -1, "Got a failure" ]
|
||||
expected_result: [-1, "Got a failure"]
|
||||
- group:
|
||||
name: Functions result success
|
||||
name: Functions result 2
|
||||
steps:
|
||||
- lua_func:
|
||||
- py_func:
|
||||
name: int success
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: echo
|
||||
param: [0]
|
||||
- lua_func:
|
||||
expected_result: 0
|
||||
- py_func:
|
||||
name: float success
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: echo
|
||||
param: [0.3]
|
||||
- lua_func:
|
||||
expected_result: 0.3
|
||||
- py_func:
|
||||
name: String success
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: echo
|
||||
param: [ "Something that is not only strictly FAIL" ]
|
||||
- lua_func:
|
||||
expected_result: Something that is not only strictly FAIL
|
||||
- py_func:
|
||||
name: Tuple int,str success
|
||||
key: $(test)_PASS
|
||||
file: $(test_path)$(psep)lua_func.lua
|
||||
file: $(test_path)$(psep)py_func.py
|
||||
func_name: tuple_return
|
||||
param: [ 0, "OK" ]
|
||||
expected_result: [0, "OK"]
|
||||
|
||||
Reference in New Issue
Block a user