Exemplo n.º 1
0
    def exclusive_changes(self, text):
        for predicate, func in self.changes:
            predicate_result = predicate(text)
            if predicate_result:
                result = func(text, predicate_result)
                if result:
                    get_logger().write("{}({!r}) -> {!r}".format(
                        func.__name__, text, result))
                return result or text

        return text
Exemplo n.º 2
0
def test_double_write():
    text = "text"
    result = "result"
    file = io.StringIO()

    text = "{!r} --> {!r}".format(text, result)
    get_logger(file).write(text)
    assert file.getvalue().strip() == text

    # Try to write the same again
    get_logger(file).write(text)
    assert file.getvalue().strip() == text
Exemplo n.º 3
0
def outer_change_text(text):
    result = change_text(text)
    get_logger().write("{}({!r}) -> {!r}".format(outer_change_text.__name__,
                                                 text, result))
    return result
Exemplo n.º 4
0
def test_cache():
    file = io.StringIO()
    assert get_logger(file) is get_logger(file)