@contextmanager
def exits_and_writes_to_stderr(match: str=''):
    s = StringIO()
    with redirect_stderr(s), raises(SystemExit):
        (yield)
    s.seek(0)
    err_string = s.read()
    if match:
        assert (match in err_string), err_string
    else:
        assert err_string, err_string
@contextmanager
def exits_and_writes_to_stderr(match: str=):
    s = StringIO()
    with redirect_stderr(s), raises(SystemExit):
        (yield)
    s.seek(0)
    err_string = s.read()
    if match:
        assert (match in err_string), err_string
    else:
        assert err_string, err_string