code: def test_security(self):
      # This test is incomplete since we are normally not run as root and
      # therefore can't test the file ownership being wrong.
      d = os_helper.TESTFN
      os.mkdir(d)
      self.addCleanup(os_helper.rmtree, d)
      fn = os.path.join(d, ".netrc")
      with open(fn, "wt") as f:
          f.write(
              """\
                  machine foo.domain.com login bar password pass
                  default login foo password pass
                  """
          )
      with os_helper.EnvironmentVarGuard() as environ:
          environ.set("HOME", d)
          os.chmod(fn, 0o600)
          nrc = netrc.netrc()
          self.assertEqual(
              nrc.hosts["foo.domain.com"], ("bar", "", "pass")
          )
          os.chmod(fn, 0o622)
          self.assertRaises(netrc.NetrcParseError, netrc.netrc)
      with open(fn, "wt") as f:
          f.write(
              """\
                  machine foo.domain.com login anonymous password pass
                  default login foo password pass
                  """
          )
      with os_helper.EnvironmentVarGuard() as environ:
          environ.set("HOME", d)
          os.chmod(fn, 0o600)
          nrc = netrc.netrc()
          self.assertEqual(
              nrc.hosts["foo.domain.com"], ("anonymous", "", "pass")
          )
          os.chmod(fn, 0o622)
          self.assertEqual(
              nrc.hosts["foo.domain.com"], ("anonymous", "", "pass")
          )
  
imports: import netrc, os, unittest, sys, textwrap
  from test.support import os_helper
label_desc: Use image node_id 25 for calling the NetrcTestCase obj's underlying member method code with example usage: obj.test_security() without return types