code: def test_cli_login_reprompts_when_no_key_specified(
      runner, mocker, dummy_api_key
  ):
      with runner.isolated_filesystem():
          mocker.patch("wandb.wandb_lib.apikey.getpass", input)
          # this first gives login an empty API key, which should cause
          # it to re-prompt.  this is what we are testing.  we then give
          # it a valid API key (the dummy API key with a different final
          # letter to check that our monkeypatch input is working as
          # expected) to terminate the prompt finally we grep for the
          # Error: No API key specified to assert that the re-prompt
          # happened
          result = runner.invoke(
              cli.login, input=f"\n{dummy_api_key[:-1]}q\n"
          )
          print(f"DEBUG(login) out = {result.output}")
          print(f"DEBUG(login) exc = {result.exception}")
          print(
              f"DEBUG(login) tb = {traceback.print_tb(result.exc_info[2])}"
          )
          with open(get_netrc_file_path()) as f:
              print(f.read())
          assert "ERROR No API key specified." in result.output
  
imports: import datetime
  import getpass
  import importlib
  import netrc
  import os
  import subprocess
  import traceback
  from unittest import mock
  import pytest
  import wandb
  from wandb.apis.internal import InternalApi
  from wandb.cli import cli
  from wandb.sdk.lib.apikey import get_netrc_file_path
label_desc: Use image node_id 13 for calling a global function with example usage: test_cli_login_reprompts_when_no_key_specified(runner, mocker, dummy_api_key) without return types