[TIP] REG: Passing custom parameters to pytest

Bruno Oliveira nicoddemus at gmail.com
Wed Aug 23 18:50:39 PDT 2017


On Wed, Aug 23, 2017 at 10:41 PM arun kali raja <arunsep886 at gmail.com>
wrote:

> I am using jenkins-like tool for doing CI and i will have  jobs for each
> release..
>
> So instead of having a text file, if the variables are mentioned in the
> invocation then it's easy for users to use it...
>

As a workaround to your original question, realize you can write a file
just as easily as passing an argument to something:

$ pytest --variables-on-cmdline=[[JSON_CONTENTS]]

can become:

$ echo [[JSON_CONTENTS]] > input.json
$ pytest --variables=input.json

But keep in mind this will need careful and complex shell escaping.

I'm sure there is a better ways to accomplish this if you would explain
your use case in more details.

Cheers,


> On 24-Aug-2017 2:04 AM, "Bruno Oliveira" <nicoddemus at gmail.com> wrote:
>
>> Hi Arun,
>>
>> On Wed, Aug 23, 2017 at 3:15 PM arun kali raja <arunsep886 at gmail.com>
>> wrote:
>>
>>>
>>> So i was thinking i will have a pytest option to accept a dict or
>>> json  (as string and then literal-eval).
>>>
>>
>> You mean passing a json or dict literal in the command line? If so it
>> doesn't seem like a good idea, dicts/json will contain a lot of special
>> characters that need to be shell-escaped.
>>
>>
>>> Or is there a better way altogether to do this..
>>>
>>
>> What's wrong with passing the variables using a file?
>>
>> Cheers,
>> Bruno.
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20170824/c92f9076/attachment.htm>


More information about the testing-in-python mailing list