play python¶
pytest-play plugin with restricted Python expressions and assertions and it is
based on the RestrictedPython
package.
RestrictedPython
is a tool that helps to define a subset of the Python
language which allows to provide a program input into a trusted environment.
RestrictedPython is not a sandbox system or a secured environment, but it helps
to define a trusted environment and execute untrusted code inside of it.
See:
More info and examples on:
- pytest-play, documentation
- cookiecutter-qa, see
pytest-play
in action with a working example if you want to start hacking
Features¶
This project defines the following pytest-play commands based on Python expressions.
Store variables¶
You can store a pytest-play variables:
{
'provider': 'python',
'type': 'store_variable',
'expression': '1+1',
'name': 'foo'
}
Make a Python assertion¶
You can make an assertion based on a Python expression:
{
'provider': 'python',
'type': 'assert',
'expression': 'variables["foo"] == 2'
}
Exec a Python expresssion¶
You can execute a Python expression:
{
'provider': 'python',
'type': 'exec',
'expression': 'variables.update({'play_requests': {'parameters': {'headers': {'Authorization': '$bearer', 'Content-Type': 'application/json'}}}})'
}
Credits¶
This package was created with Cookiecutter and the cookiecutter-play-plugin (based on audreyr/cookiecutter-pypackage project template).