MCPcopy Index your code
hub / github.com/python/cpython / check_info

Method check_info

Lib/test/test_mailbox.py:884–905  ·  view source on GitHub ↗
(oldinfo, newinfo)

Source from the content-addressed store, hash-verified

882 msg = mailbox.MaildirMessage(self._template % 0)
883 key = self._box.add(msg)
884 def check_info(oldinfo, newinfo):
885 oldfilename = os.path.join(self._box._path, self._box._lookup(key))
886 newsubpath = self._box._lookup(key).split(self._box.colon)[0]
887 if newinfo:
888 newsubpath += self._box.colon + newinfo
889 newfilename = os.path.join(self._box._path, newsubpath)
890 # assert initial conditions
891 self.assertEqual(self._box.get_info(key), oldinfo)
892 if not oldinfo:
893 self.assertNotIn(self._box._lookup(key), self._box.colon)
894 self.assertTrue(os.path.exists(oldfilename))
895 if oldinfo != newinfo:
896 self.assertFalse(os.path.exists(newfilename))
897 # do the rename
898 self._box.set_info(key, newinfo)
899 # assert post conditions
900 if not newinfo:
901 self.assertNotIn(self._box._lookup(key), self._box.colon)
902 if oldinfo != newinfo:
903 self.assertFalse(os.path.exists(oldfilename))
904 self.assertTrue(os.path.exists(newfilename))
905 self.assertEqual(self._box.get_info(key), newinfo)
906 # none -> has info
907 check_info('', 'info1')
908 # has info -> same info

Callers

nothing calls this directly

Calls 10

assertNotInMethod · 0.80
assertTrueMethod · 0.80
assertFalseMethod · 0.80
joinMethod · 0.45
_lookupMethod · 0.45
splitMethod · 0.45
assertEqualMethod · 0.45
get_infoMethod · 0.45
existsMethod · 0.45
set_infoMethod · 0.45

Tested by

no test coverage detected