[Python] How to mock a dictionary in Python

Discussão em 'Python' iniciado por Stack, Maio 21, 2025.

  1. Stack

    Stack Membro Participativo

    Let's say I have a function like this:

    def do_something(dict_obj):
    # access to the dict_obj then do some stuff
    eg.
    if dict_obj['doors']:
    do_something_with_doors()
    map_car_make(dict_obj['make'])
    ...

    if dict_obj['is_active']:
    do_something_else()


    I want to mock the dict_obj to have is_active element and don't care the rest, how do I do that?

    Continue reading...

Compartilhe esta Página