use the following pytest feature instead of this logic:
with pytest.raises(subprocess.CalledProcessError):
    check_run_shell(command, shell=True)