def assertEqual(self, first: Any, second: Any, msg: Text = "") -> None:
     if isinstance(first, Text) and isinstance(second, Text):
         if first != second:
             raise AssertionError("Actual and expected outputs do not match; showing diff.\n" +
                                  mdiff.diff_strings(first, second) + msg)
     else:
         super().assertEqual(first, second)
Esempio n. 2
0
def assertLength(result, fixture):
    # type: (Dict[str, Any], Dict[str, Any]) -> None
    if len(result) != len(fixture):
        result_string = json.dumps(result, indent=4, sort_keys=True)
        fixture_string = json.dumps(fixture, indent=4, sort_keys=True)
        raise AssertionError("The lengths of the actual and expected outputs do not match; showing diff:\n" +
                             mdiff.diff_strings(result_string, fixture_string))
    else:
        assert len(result) == len(fixture)
Esempio n. 3
0
def assertEqual(key, result, fixture):
    # type: (str, Dict[str, Any], Dict[str, Any]) -> None
    if result[key] != fixture[key]:
        first = "{key} = {value}".format(key=key, value=result[key])
        second = "{key} = {value}".format(key=key, value=fixture[key])
        raise AssertionError("Actual and expected outputs do not match; showing diff:\n" +
                             mdiff.diff_strings(first, second))
    else:
        assert result[key] == fixture[key]
Esempio n. 4
0
def assertLength(result, fixture):
    # type: (Dict[str, Any], Dict[str, Any]) -> None
    if len(result) != len(fixture):
        result_string = json.dumps(result, indent=4, sort_keys=True)
        fixture_string = json.dumps(fixture, indent=4, sort_keys=True)
        raise AssertionError("The lengths of the actual and expected outputs do not match; showing diff:\n" +
                             mdiff.diff_strings(result_string, fixture_string))
    else:
        assert len(result) == len(fixture)
Esempio n. 5
0
def assertEqual(key, result, fixture):
    # type: (str, Dict[str, Any], Dict[str, Any]) -> None
    if result[key] != fixture[key]:
        first = "{key} = {value}".format(key=key, value=result[key])
        second = "{key} = {value}".format(key=key, value=fixture[key])
        raise AssertionError("Actual and expected outputs do not match; showing diff:\n" +
                             mdiff.diff_strings(first, second))
    else:
        assert result[key] == fixture[key]
Esempio n. 6
0
def assertEqual(key: str, result: Dict[str, Any], fixture: Dict[str,
                                                                Any]) -> None:
    if result[key] != fixture[key]:
        first = f"{key} = {result[key]}"
        second = f"{key} = {fixture[key]}"
        raise AssertionError(
            "Actual and expected outputs do not match; showing diff:\n" +
            mdiff.diff_strings(first, second))
    else:
        assert result[key] == fixture[key]