(test_case)
| 46 | |
| 47 | @pytest.mark.parametrize("test_case", TESTS_THAT_PASS) |
| 48 | def test_json_example(test_case): |
| 49 | # Run one example from the data file |
| 50 | orig = test_case["original"] |
| 51 | fixed = test_case["fixed"] |
| 52 | |
| 53 | # Make sure that we can fix the text as intended |
| 54 | assert fix_text(orig) == fixed |
| 55 | |
| 56 | # Make sure that fix_and_explain outputs a plan that we can successfully |
| 57 | # run to reproduce its result |
| 58 | fixed_output, plan = fix_and_explain(orig) |
| 59 | assert apply_plan(orig, plan) == fixed_output |
| 60 | |
| 61 | # Do the same for fix_encoding_and_explain |
| 62 | encoding_fix, plan = fix_encoding_and_explain(orig) |
| 63 | assert apply_plan(orig, plan) == encoding_fix |
| 64 | |
| 65 | # Ask for the encoding fix a different way, by disabling all the other steps |
| 66 | # in the config object |
| 67 | assert ( |
| 68 | fix_text( |
| 69 | orig, |
| 70 | unescape_html=False, |
| 71 | remove_terminal_escapes=False, |
| 72 | fix_character_width=False, |
| 73 | fix_latin_ligatures=False, |
| 74 | uncurl_quotes=False, |
| 75 | fix_line_breaks=False, |
| 76 | fix_surrogates=False, |
| 77 | remove_control_chars=False, |
| 78 | normalization=None, |
| 79 | ) |
| 80 | == encoding_fix |
| 81 | ) |
| 82 | |
| 83 | # Make sure we can decode the text as intended |
| 84 | assert fix_text(orig) == fixed |
| 85 | assert encoding_fix == test_case.get("fixed-encoding", fixed) |
| 86 | |
| 87 | # Make sure we can decode as intended even with an extra layer of badness |
| 88 | extra_bad = orig.encode("utf-8").decode("latin-1") |
| 89 | assert fix_text(extra_bad) == fixed |
| 90 | |
| 91 | |
| 92 | @pytest.mark.parametrize("test_case", TESTS_THAT_FAIL) |
nothing calls this directly
no test coverage detected