@@ -620,7 +620,7 @@ def test_embedded_correction_schedules_both_mixed_case_interpretations_before_al
620620 source = "ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxx4nzvca9cmczlw"
621621 damaged = "ms10testsxPxxxxxPxxxxxPxxxxxPxxxxxP4nzvca9cmczlw"
622622
623- candidates = input_module ._suggestions (damaged , "" , (Profile .MS ,), [])
623+ candidates , _complete = input_module ._suggestions (damaged , "" , (Profile .MS ,), [])
624624
625625 assert len (candidates ) == 1
626626 assert candidates [0 ].artifact .text == source
@@ -660,9 +660,7 @@ def test_xprv_rejects_unreadable_entries_without_edit_hints(monkeypatch, capsys)
660660 assert ms_main (["xprv" ]) == 0
661661 rejected = [line for line in capsys .readouterr ().err .splitlines () if line .startswith ("Rejected:" )]
662662 # A hint about what is wrong invites a guess, and a wrong guess can make a wrong correction findable.
663- assert (
664- rejected == ["Rejected: No unique correction found. Check your backup and re-enter it carefully." ] * 2
665- )
663+ assert rejected == ["Rejected: No correction was found. Check your backup and re-enter it carefully." ] * 2
666664
667665
668666def test_xprv_rejects_every_uncorrectable_prefixed_ms_length (monkeypatch , capsys ) -> None :
@@ -678,7 +676,7 @@ def test_xprv_rejects_every_uncorrectable_prefixed_ms_length(monkeypatch, capsys
678676 assert ms_main (["xprv" ]) == 0
679677 output = capsys .readouterr ().err
680678 assert output .count (
681- "Rejected: No unique correction found. Check your backup and re-enter it carefully."
679+ "Rejected: No correction was found. Check your backup and re-enter it carefully."
682680 ) == len (lengths )
683681 assert "characters" not in output
684682
@@ -692,7 +690,7 @@ def test_prefixed_ms_lengths_at_correction_boundary_still_search(monkeypatch, ca
692690
693691 def suggestions (value , * _args , ** _kwargs ):
694692 searched .append (value )
695- return ()
693+ return (), True
696694
697695 monkeypatch .setattr (input_module .sys , "stdin" , _TTYInput ())
698696 monkeypatch .setattr (input_module , "_line_editor" , None )
@@ -703,7 +701,7 @@ def suggestions(value, *_args, **_kwargs):
703701 output = capsys .readouterr ().err
704702 assert [len (value ) for value in searched ] == list (lengths )
705703 assert output .count (
706- "Rejected: No unique correction found. Check your backup and re-enter it carefully."
704+ "Rejected: No correction was found. Check your backup and re-enter it carefully."
707705 ) == len (lengths )
708706
709707
@@ -714,35 +712,55 @@ def test_complete_paste_with_bad_threshold_gets_no_hint(monkeypatch, capsys) ->
714712 monkeypatch .setattr (input_module .sys , "stdin" , _TTYInput ())
715713 monkeypatch .setattr (input_module , "_line_editor" , None )
716714 monkeypatch .setattr (input_module , "_editable_input" , lambda _prompt , _prefill = "" : next (answers ))
717- monkeypatch .setattr (input_module , "_suggestions" , lambda * _args , ** _kwargs : ())
715+ monkeypatch .setattr (input_module , "_suggestions" , lambda * _args , ** _kwargs : ((), True ))
718716
719717 assert ms_main (["xprv" ]) == 0
720718 output = capsys .readouterr ().err
721- assert "Rejected: No unique correction found. Check your backup and re-enter it carefully." in output
719+ assert "Rejected: No correction was found. Check your backup and re-enter it carefully." in output
722720 assert "threshold" not in output
723721
724722
725723def test_redirected_uncorrectable_input_gets_no_hint (monkeypatch ) -> None :
726724 input_module = importlib .import_module ("codex32._cli_input" )
727- monkeypatch .setattr (input_module , "_suggestions" , lambda * _args , ** _kwargs : ())
725+ monkeypatch .setattr (input_module , "_suggestions" , lambda * _args , ** _kwargs : ((), True ))
728726
729727 result = _invoke (["secret" ], VECTOR_1 ["secret_s" ][:- 1 ] + "b" )
730728
731729 assert result .exit_code != 0
732- assert "No unique correction found. Check your backup and re-enter it carefully." in result .stderr
730+ assert "No correction was found. Check your backup and re-enter it carefully." in result .stderr
733731 assert "character" not in result .stderr
734732
735733
734+ @pytest .mark .parametrize (
735+ ("result" , "reason" ),
736+ (
737+ (((), True ), "No correction was found." ),
738+ (((), False ), "The correction search ran out of time." ),
739+ (((object (), object ()), True ), "Several corrections are possible." ),
740+ ),
741+ )
742+ def test_redirected_rejection_says_why_no_correction_is_shown (monkeypatch , result , reason ) -> None :
743+ input_module = importlib .import_module ("codex32._cli_input" )
744+ monkeypatch .setattr (input_module , "_suggestions" , lambda * _args , ** _kwargs : result )
745+
746+ rejected = _invoke (["secret" ], VECTOR_1 ["secret_s" ][:- 1 ] + "b" )
747+
748+ assert rejected .exit_code != 0
749+ # Say what happened, never how to edit the entry.
750+ assert f"{ reason } Check your backup and re-enter it carefully." in rejected .stderr
751+ assert "character" not in rejected .stderr
752+
753+
736754def test_existing_seed_without_unique_correction_gets_no_hint (monkeypatch , capsys ) -> None :
737755 cli_module = importlib .import_module ("codex32.cli" )
738756 answers = iter ((VECTOR_1 ["secret_s" ][:- 1 ] + "b" , "00" * 16 ))
739757 monkeypatch .setattr (cli_module .sys , "stdin" , _TTYInput ())
740758 monkeypatch .setattr (cli_module , "_text" , lambda * _args , ** _kwargs : next (answers ))
741- monkeypatch .setattr (cli_module , "_suggestions" , lambda * _args , ** _kwargs : ())
759+ monkeypatch .setattr (cli_module , "_suggestions" , lambda * _args , ** _kwargs : ((), True ))
742760
743761 assert cli_module ._creation_source (Profile .MS ) == bytes (16 )
744762 assert capsys .readouterr ().err == (
745- "Rejected: No unique correction found. Check your codex32 backup and re-enter it carefully.\n "
763+ "Rejected: No correction was found. Check your backup and re-enter it carefully.\n "
746764 )
747765
748766
@@ -768,7 +786,7 @@ def answer(*_args, **kwargs):
768786 assert seen_prefills == ["" , "" ]
769787 output = capsys .readouterr ().err
770788 assert "Hexadecimal seeds must contain 16, 20, 24, 28, 32, or 64 bytes" in output
771- assert "No unique correction" not in output
789+ assert "correction" not in output
772790
773791
774792@pytest .mark .parametrize (("difference" , "word" ), ((- 9 , "short of" ), (9 , "too long for" )))
@@ -788,7 +806,7 @@ def test_subsequent_prefixed_ms_input_with_wrong_length_gets_no_hint(
788806 assert main (["secret" , "--plain" ]) == 0
789807 output = capsys .readouterr ()
790808 assert output .out .strip () == VECTOR_2 ["secret_S" ]
791- assert "Rejected: No unique correction found. Check your backup and re-enter it carefully." in output .err
809+ assert "Rejected: No correction was found. Check your backup and re-enter it carefully." in output .err
792810 assert word not in output .err
793811
794812
@@ -1847,7 +1865,7 @@ def test_cli_rejects_statistically_inadmissible_structural_burst() -> None:
18471865 result = _invoke (["correct" ], damaged )
18481866
18491867 assert result .exit_code == 3
1850- assert "No valid correction found" in result .stderr
1868+ assert "No correction was found" in result .stderr
18511869
18521870
18531871def test_cli_rejects_sixteen_consecutive_erasures_as_outside_regular_bound () -> None :
@@ -1858,7 +1876,7 @@ def test_cli_rejects_sixteen_consecutive_erasures_as_outside_regular_bound() ->
18581876 assert len ("" .join (damaged .split ())) == 48
18591877 assert damaged .count ("?" ) == 16
18601878 assert result .exit_code == 3
1861- assert "No valid correction found" in result .stderr
1879+ assert "No correction was found" in result .stderr
18621880
18631881
18641882def test_correct_rejects_malformed_immutable_hrp_as_usage () -> None :
@@ -1910,7 +1928,7 @@ def test_cli_never_accepts_an_incomplete_structural_search() -> None:
19101928
19111929 assert result .exit_code == 3
19121930 assert result .stdout == ""
1913- assert "did not complete " in result .stderr and original not in result .stderr
1931+ assert "ran out of time " in result .stderr and original not in result .stderr
19141932
19151933
19161934@pytest .mark .parametrize (
@@ -1997,7 +2015,7 @@ def test_correct_suggests_the_majority_case_for_mixed_case_damage() -> None:
19972015
19982016 assert result .exit_code == 1
19992017 assert source in result .stderr
2000- assert "No valid correction found" not in result .stderr
2018+ assert "No correction was found" not in result .stderr
20012019 assert wrong_length .exit_code == 2
20022020 assert "--bytes does not match" in wrong_length .stderr
20032021 assert source not in wrong_length .stderr
@@ -2069,7 +2087,7 @@ def test_correct_required_work_is_not_starved_by_erasure_alignment() -> None:
20692087
20702088 assert result .exit_code == 1
20712089 assert source in result .stderr
2072- assert "did not complete within ten seconds " not in result .stderr
2090+ assert "ran out of time " not in result .stderr
20732091 assert "interactive confirmation required" not in result .stderr
20742092
20752093
@@ -2118,8 +2136,8 @@ def test_correction_hides_internal_candidate_reparse_failures() -> None:
21182136 assert result .exit_code == 3
21192137 assert result .stdout == ""
21202138 assert result .stderr .strip () in {
2121- "codex32 correct: No valid correction found. Check the original backup." ,
2122- "codex32 correct: The correction search did not complete within ten seconds ." ,
2139+ "codex32 correct: No correction was found. Check your backup and re-enter it carefully ." ,
2140+ "codex32 correct: The correction search ran out of time. Check your backup and re-enter it carefully ." ,
21232141 }
21242142 assert "threshold" not in result .stderr
21252143
@@ -2876,7 +2894,7 @@ def test_creation_source_unusable_candidates_retry(monkeypatch, capsys, kind):
28762894 artifact = parse_codex32 (VECTOR_6 ["codex32_peev" ])
28772895 candidate = SimpleNamespace (artifact = artifact , search_complete = True , low_checksum_discrimination = False )
28782896 candidates = () if kind == "none" else (candidate , candidate ) if kind == "ambiguous" else (candidate ,)
2879- monkeypatch .setattr (cli , "_suggestions" , lambda * args , ** kwargs : candidates )
2897+ monkeypatch .setattr (cli , "_suggestions" , lambda * args , ** kwargs : ( candidates , True ) )
28802898 answers = iter (("ms1invalid" , "00" * 16 ))
28812899 monkeypatch .setattr (sys , "stdin" , _TTYInput ())
28822900 monkeypatch .setattr (module , "_editable_input" , lambda * args : next (answers ))
@@ -2903,7 +2921,7 @@ def test_creation_source_does_not_label_an_incomplete_share_candidate(monkeypatc
29032921
29042922 def suggestions (* args , ** kwargs ):
29052923 assert not kwargs ["allowed" ](candidate )
2906- return (candidate ,)
2924+ return (candidate ,), True
29072925
29082926 monkeypatch .setattr (sys , "stdin" , _TTYInput ())
29092927 monkeypatch .setattr (module , "_editable_input" , lambda * args : next (answers ))
@@ -2930,7 +2948,7 @@ def answer(*args):
29302948
29312949 monkeypatch .setattr (sys , "stdin" , _TTYInput ())
29322950 monkeypatch .setattr (module , "_editable_input" , answer )
2933- monkeypatch .setattr (cli , "_suggestions" , lambda * args , ** kwargs : ())
2951+ monkeypatch .setattr (cli , "_suggestions" , lambda * args , ** kwargs : ((), True ))
29342952 with pytest .raises (exception ):
29352953 cli ._creation_source (Profile .MS )
29362954
@@ -2981,7 +2999,8 @@ def test_corrected_creation_source_identity_and_acceptance_boundary(monkeypatch)
29812999 cli ,
29823000 "_suggestions" ,
29833001 lambda * args , ** kwargs : (
2984- SimpleNamespace (artifact = secret , search_complete = True , low_checksum_discrimination = False ),
3002+ (SimpleNamespace (artifact = secret , search_complete = True , low_checksum_discrimination = False ),),
3003+ True ,
29853004 ),
29863005 )
29873006 answers = iter (("ms1invalid" , "n" , "ms1invalid" , "yes" , "" , secret .text ))
0 commit comments