Author Dennis Sweeney
Recipients Dennis Sweeney, pablogsal, shreyanavigyan, terry.reedy
Date 2021-05-04.20:16:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1620159382.88.0.0479058102113.issue44026@roundup.psfhosted.org>
In-reply-to
Content
Another idea: do what test_exceptions() does:

        try:
            f()
        except NameError as exc:
            with support.captured_stderr() as err:
                sys.__excepthook__(*sys.exc_info())

        self.assertNotIn("a1", err.getvalue())

Then instead of the assert, do something like

    last_line = err.getvalue().rsplit("\n", 2)[-2]
    _, did_you_mean, suggestion = last_line.rpartition("Did you mean: ")
    if did_you_mean:
       print(did_you_mean + suggestion)

This can probably be done without test.support.
History
Date User Action Args
2021-05-04 20:16:22Dennis Sweeneysetrecipients: + Dennis Sweeney, terry.reedy, pablogsal, shreyanavigyan
2021-05-04 20:16:22Dennis Sweeneysetmessageid: <1620159382.88.0.0479058102113.issue44026@roundup.psfhosted.org>
2021-05-04 20:16:22Dennis Sweeneylinkissue44026 messages
2021-05-04 20:16:22Dennis Sweeneycreate