[Python] What is the best way to compare 2 Python dictionaries and translate this Python code...

Discussão em 'Python' iniciado por Stack, Novembro 29, 2024.

  1. Stack

    Stack Membro Participativo

    Both message and expected_result variables are dict()

    assert message == expected_result
    isequal=(message==expected_result)


    Both message and expected_result are dict() type.

    After asking ChatGPT, I was told to change the code in this way:

    Assert.That(message, [Is].EqualTo(expectedResult))
    Dim isEqual As Boolean = message.Equals(expectedResult)


    Basically I have this thing called Nunit.Framework with a class named "Is" but it only works in assertion.

    I can't get it to yield normal boolean.

    And with Equals I have doubt. It may be able to test equality for simple dictionary, but what about dictionary containing dictionary?

    Let's just say the name of the key are always string.

    So I use dictionary(of string, object)

    Continue reading...

Compartilhe esta Página