Example #1
0
def test_put_info_nested():
    e = Error(a=1, b=1, c=1)
    e.put_info("a={a} b={b} c={c}", a=2, b=2)
    e.put_info("a={a} b={b} c={c}", a=3)

    assert e.info_strs == [
        "a=2 b=2 c=1",
        "a=3 b=2 c=1",
    ]
Example #2
0
class Log:
    def __init__(self):
        # This is a bit of a hack.  We're just using the error class for its
        # formatting features.
        #
        # If I ever get around to refactoring this, note that the unit tests
        # rely on being able to access list of all log messages with parameters
        # substituted but without bullet points applied.
        self._err = Error()

    def __str__(self):
        return str(self._err)

    def info(self, message, **kwargs):
        self._err.put_info(message, **kwargs)

    def hint(self, message):
        self._err.info += message
Example #3
0
def test_put_info():
    e = Error(a=1, z=-1)
    e.info += "a={a}"
    e.put_info("a={a}")
    e.put_info("b={b}", b=2)
    e.put_info("b={b}", "c={c}", c=3)
    e.info += "z={z}"

    assert e.info_strs == [
        "a=1",
        "a=1",
        "b=2",
        "b=2",
        "c=3",
        "z=-1",
    ]