Source

araldo / test / util_test.py

import pytest
from mock import Mock, call
from araldo import util


@pytest.fixture
def logger():
    return Mock()


@pytest.mark.parametrize(("dump_args", "expected_log_args"), [
    ([{"a": "b"}], call('%s%s', '', "{'a': 'b'}\n")),
    ([{"a": "b"}, "descr1"], call('%s%s', 'descr1', "{'a': 'b'}\n")),
])
def test_dump_obj_no_description(dump_args, expected_log_args, logger):
    dump_args = dump_args[0:1] + [logger] + dump_args[1:]
    util.dump_obj(*dump_args)
    assert expected_log_args, logger.debug.call_args