Files
testium/test/validation/items/py_func/py_func.py
François d92f518e1e Add context_id to py_func and lua_func for shared persistent subprocess
- py_func and lua_func items accept a context_id parameter; items sharing
  the same id reuse the same subprocess for the duration of the test run
- Subprocess-side tm.setgd/tm.gd use a local fallback dict for non-JSON-
  serializable values (py_func only); serializable values reach the main
  process global dict and are accessible from any test item or subprocess
- Shared subprocess engines are cleaned up in process.py finally block
- LuaProcessBase gains is_alive() (was missing, broke all lua_func items)
- Validation tests cover serializable sharing across different context ids,
  non-serializable sharing within the same context_id, and cross-item access
- RST documentation updated for both py_func and lua_func items

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 16:02:36 +02:00

50 lines
983 B
Python

import py_func.tm as tm
class ValidationTest(tm.FunctionItem):
def exec(self, param):
print(str(param))
return 0
def donothing():
return 0
def assertparam(param):
assert param
return 0
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
def echo(param):
return param
def tuple_return(first, second):
return first, second
def set_context_value(val):
tm.setgd("_py_ctx_test_value", val)
return val
def get_context_value():
return tm.gd("_py_ctx_test_value", None)
class _NotSerializable:
def __init__(self, val):
self.val = val
def set_ns_value(val):
tm.setgd("_py_ctx_ns_value", _NotSerializable(val))
return val
def get_ns_value():
obj = tm.gd("_py_ctx_ns_value", None)
return obj.val if obj is not None else None