Modify context from a proteus script

How can I modify the context from a proteus script? I tried
config.set_context(something=value)
but it doesn’t work.

set_context returns a context manager so you must put inside with statement like:

with config.set_context(something=value):
    # call method

Initially I had tried:

SomeTrytonModel = Model.get('some.tryton.model')
conf = config.set_trytond(database, config_file=trytond_config)
objects_to_delete = [List of objects to delete recovered using SomeTrytonModel.search]
with conf.set_context(something=value):
....SomeTrytonModel.delete(objects_to_delete)

But it didn’t work, where is the error?

In “SomeTrytonModel” I have redefined the “delete” method in order to it has a behavior depending on the value sent by the context, however, when debugging, I noticed that the variable sent to the context through the proteus script never arrives. It’s like if the context was not modified.

The delete method uses the context of the instance and not the current context (this is to mimic the client behavior).
So you must instantiate the list of records to delete inside the “with” statement.