code: def test_create_pypirc(self):
      # this test makes sure a .pypirc file
      # is created when requested.
  
      # let's create a register instance
      cmd = self._get_cmd()
  
      # we shouldn't have a .pypirc file yet
      self.assertFalse(os.path.exists(self.rc))
  
      # patching raw_input and getpass.getpass
      # so register gets happy
      #
      # Here's what we are faking :
      # use your existing login (choice 1.)
      # Username : 'tarek'
      # Password : 'password'
      # Save your login (y/N)? : 'y'
      inputs = RawInputs("1", "tarek", "y")
      register_module.raw_input = inputs.__call__
      # let's run the command
      try:
          cmd.run()
      finally:
          del register_module.raw_input
  
      # we should have a brand new .pypirc file
      self.assertTrue(os.path.exists(self.rc))
  
      # with the content similar to WANTED_PYPIRC
      f = open(self.rc)
      try:
          content = f.read()
          self.assertEqual(content, WANTED_PYPIRC)
      finally:
          f.close()
  
      # now let's make sure the .pypirc file generated
      # really works : we shouldn't be asked anything
      # if we run the command again
      def _no_way(prompt=""):
          raise AssertionError(prompt)
  
      register_module.raw_input = _no_way
  
      cmd.show_response = 1
      cmd.run()
  
      # let's see what the server received : we should
      # have 2 similar requests
      self.assertEqual(len(self.conn.reqs), 2)
      req1 = dict(self.conn.reqs[0].headers)
      req2 = dict(self.conn.reqs[1].headers)
      self.assertEqual(req2["Content-length"], req1["Content-length"])
      self.assertIn("xxx", self.conn.reqs[1].data)
  
imports: import os
  import unittest
  import getpass
  import urllib2
  import warnings
  from test.test_support import check_warnings, run_unittest
  from distutils.command import register
  from distutils.command.register import register
  from distutils.errors import DistutilsSetupError
  from distutils.tests.test_config import PyPIRCCommandTestCase
label_desc: Use image node_id 4 for calling the RegisterTestCase obj's underlying member method code with example usage: obj.test_create_pypirc() without return types