def test_listmailcapfiles(self): mcfiles = mailcap.listmailcapfiles() self.assertIsInstance(mcfiles, list) for m in mcfiles: self.assertIsInstance(m, str) with test.support.EnvironmentVarGuard() as env: if 'MAILCAPS' in env: env_mailcaps = env['MAILCAPS'].split(os.pathsep) else: env_mailcaps = ['/testdir1/.mailcap', '/testdir2/mailcap'] env['MAILCAPS'] = os.pathsep.join(env_mailcaps) mcfiles = mailcap.listmailcapfiles() self.assertEqual(env_mailcaps, mcfiles)
def test_listmailcapfiles(self): # The return value for listmailcapfiles() will vary by system. # So verify that listmailcapfiles() returns a list of strings that is of # non-zero length. mcfiles = mailcap.listmailcapfiles() self.assertIsInstance(mcfiles, list) for m in mcfiles: self.assertIsInstance(m, str) with test.support.EnvironmentVarGuard() as env: # According to RFC 1524, if MAILCAPS env variable exists, use that # and only that. if "MAILCAPS" in env: env_mailcaps = env["MAILCAPS"].split(os.pathsep) else: env_mailcaps = ["/testdir1/.mailcap", "/testdir2/mailcap"] env["MAILCAPS"] = os.pathsep.join(env_mailcaps) mcfiles = mailcap.listmailcapfiles() self.assertEqual(env_mailcaps, mcfiles)
def test_system_mailcap(self): caps = mailcap.getcaps() self.assertIsInstance(caps, dict) mailcapfiles = mailcap.listmailcapfiles() existingmcfiles = [mcf for mcf in mailcapfiles if os.path.exists(mcf)] if existingmcfiles: for k, v in caps.items(): self.assertIsInstance(k, str) self.assertIsInstance(v, list) for e in v: self.assertIsInstance(e, dict) else: self.assertEqual({}, caps)
def test_system_mailcap(self): # Test mailcap.getcaps() with mailcap file(s) on system, if any. caps = mailcap.getcaps() self.assertIsInstance(caps, dict) mailcapfiles = mailcap.listmailcapfiles() existingmcfiles = [mcf for mcf in mailcapfiles if os.path.exists(mcf)] if existingmcfiles: # At least 1 mailcap file exists, so test that. for (k, v) in caps.items(): self.assertIsInstance(k, str) self.assertIsInstance(v, list) for e in v: self.assertIsInstance(e, dict) else: # No mailcap files on system. getcaps() should return empty dict. self.assertEqual({}, caps)
def update_event(self, inp=-1): self.set_output_val(0, mailcap.listmailcapfiles())