def transform_source(source, callback_params=None, **kwargs): """This function is called by the import hook loader and uses transformations from two other examples. """ if callback_params["show_original"]: utils.print_source(source, "Original") source = french.french_to_english(source) source = repeat.convert_repeat(source) if callback_params["show_transformed"]: utils.print_source(source, "Transformed") return source
def test_repeat_while(): source = "repeat while condition:" # note extra space between while and condition as we removed a keyword assert repeat.convert_repeat(source) == "while condition:"
def test_repeat_until(): source = "repeat until condition: # a comment" assert repeat.convert_repeat(source) == "while not condition: # a comment"
def test_repeat_forever(): source = " repeat forever:" assert repeat.convert_repeat( source) == " while True:", "repeat forever test"
def test_predictable(): assert converted == repeat.convert_repeat( source, predictable_names=True), "Testing predicted conversion."