play python

https://img.shields.io/pypi/v/play_python.svg https://img.shields.io/travis/tierratelematics/play_python.svg Documentation Status

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:

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'
}

Sleep

Sleep for a given amount of seconds:

{
 'provider': 'python',
 'type': 'sleep',
 'seconds': 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'}}}})'
}

Twitter

pytest-play tweets happens here:

Credits

This package was created with Cookiecutter and the cookiecutter-play-plugin (based on audreyr/cookiecutter-pypackage project template).