[pytest-dev] autospec for monkeypatch
Brian Okken
variedthoughts at gmail.com
Sun Mar 21 18:46:08 EDT 2021
Yep. I think that’s it. I totally forgot about raising. I’ll try it out.
- Brian
> On Mar 21, 2021, at 1:06 PM, Bruno Oliveira <nicoddemus at gmail.com> wrote:
>
>
> > there is no option to only accept existing keys.
>
> I'm not sure what they mean... there's a `raising` keyword argument, which defaults to True.
>
> []
> Bruno
>
>> On Sun, Mar 21, 2021 at 2:41 PM Brian Okken <variedthoughts at gmail.com> wrote:
>> I think I want to get some extra help on this good question.
>> - Brian
>>
>> - Brian
>>
>> Begin forwarded message:
>>
>>> From: Dimitri Blyumin via Fireside <contactform at fireside.fm>
>>> Date: March 20, 2021 at 7:36:58 PM PDT
>>> To: brian at pythontesting.net
>>> Subject: [Test & Code : Python Testing] Listener Feedback from Dimitri Blyumin
>>> Reply-To: dimitri.blyumin at gmail.com
>>>
>>> Name: Dimitri Blyumin
>>> Email: dimitri.blyumin at gmail.com
>>> Twitter:
>>> Website:
>>>
>>> Hi Brian,
>>> I'm going through your excellent "Python Testing with pytest" book, and came across this potential scenario in monkeypatching: if we use setitem and misspell the key - it will create a new key:value and will leave the original one as is, no KeyError or warning.
>>> Looking at the docs - there is no option to only accept existing keys.
>>> I think this can be dangerous in some cases when the user expects a value to be patched, and it is not, e.g. change environment in the config dict from PRD to DEV.
>>> Did you encounter this and is there a way to ensure that only existing keys are used in patching?
>>>
>>>
>>> --
>>> Fireside Labs, LLC (http://fireside.fm/)
>> _______________________________________________
>> 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: <https://mail.python.org/pipermail/pytest-dev/attachments/20210321/fa36eafc/attachment.html>
More information about the pytest-dev
mailing list