[pytest-dev] How to duplicate pytest.Item inside function 'pytest_collection_modifyitems'?

Ronny Pfannschmidt opensource at ronnypfannschmidt.de
Wed Apr 15 04:25:37 EDT 2020


*copey with the correct mail*

Hi Shiban,

its not safely possible to clone a item in general.

A) you need to make a new nodeid to prevent some issues

B) there is no safe cloning mechanism declared, different subtypes of 
items have different mutable state you dont want to mix

I believe the closest you can get is creating a new item that is 
reasonably equivalent.
The Details of that would depend on what the actual Item subtype is.

-- Ronny

Am 15.04.20 um 07:45 schrieb Ronny Pfannschmidt:
>
> Hi Shiban,
>
> its not safely possible to clone a item in general.
>
> A) you need to make a new nodeid to prevent some issues
>
> B) there is no safe cloning mechanism declared, different subtypes of 
> items have different mutable state you dont want to mix
>
> I believe the closest you can get is creating a new item that is 
> reasonably equivalent.
> The Details of that would depend on what the actual Item subtype is.
>
> -- Ronny
>
> Am 14.04.20 um 23:46 schrieb Anton Shiban:
>>
>> Hi,
>>
>>
>> Can you please guide me *how to* *clone pytest.Item?*
>>
>> I want to take one *item* from *items* array (inside function 
>> ‘pytest_collection_modifyitems’) and clone that *item* and add it to 
>> *items* array back.
>>
>> Can someone please guide to do this?
>>
>>
>> Thanks,
>>
>> Shiban.
>>
>>
>> _______________________________________________
>> pytest-dev mailing list
>> pytest-dev at python.org
>> https://mail.python.org/mailman/listinfo/pytest-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20200415/8b49d4e8/attachment-0001.html>


More information about the pytest-dev mailing list