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

Method createMessage

Lib/test/test_mailbox.py:2350–2368  ·  view source on GitHub ↗
(self, dir, mbox=False)

Source from the content-addressed store, hash-verified

2348 os_helper.rmdir(self._dir)
2349
2350 def createMessage(self, dir, mbox=False):
2351 t = int(time.time() % 1000000)
2352 pid = self._counter
2353 self._counter += 1
2354 filename = ".".join((str(t), str(pid), "myhostname", "mydomain"))
2355 tmpname = os.path.join(self._dir, "tmp", filename)
2356 newname = os.path.join(self._dir, dir, filename)
2357 with open(tmpname, "w", encoding="utf-8") as fp:
2358 self._msgfiles.append(tmpname)
2359 if mbox:
2360 fp.write(FROM_)
2361 fp.write(DUMMY_MESSAGE)
2362 try:
2363 os.link(tmpname, newname)
2364 except (AttributeError, PermissionError):
2365 with open(newname, "w") as fp:
2366 fp.write(DUMMY_MESSAGE)
2367 self._msgfiles.append(newname)
2368 return tmpname
2369
2370 def test_empty_maildir(self):
2371 """Test an empty maildir mailbox"""

Callers 3

Calls 6

strFunction · 0.85
openFunction · 0.50
timeMethod · 0.45
joinMethod · 0.45
appendMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected