""" Verifies the worked example from instructions.md line by line. The end-to-end behaviour of that same example, including the sort order and the printed output, is covered by tests/integration/test_cli.py. """ import pytest from replacer import prepare_pairs, replace_line SAMPLE_PAIRS = prepare_pairs([("a", "z"), ("bb", "y"), ("c", "x")]) # Each sample line mapped to its expected result and replacement count. EXPECTED_RESULTS = { "jgrebbk6hnae": ("jgreyk6hnze", 3), "cnhjrfyjvth3nxr": ("xnhjrfyjvth3nxr", 1), "b#sjcf_ansbbbbbvo!": ("b#sjxf_znsyybvo!", 6), "dajf#aemfaocfna%": ("dzjf#zemfzoxfnz%", 5), } @pytest.mark.parametrize("line", list(EXPECTED_RESULTS)) def test_each_sample_line(line): expected_result, expected_replaced = EXPECTED_RESULTS[line] result, replaced = replace_line(line, SAMPLE_PAIRS) assert result == expected_result assert replaced == expected_replaced