MCPcopy Index your code
hub / github.com/RustPython/RustPython / createMessage

Method createMessage

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

Source from the content-addressed store, hash-verified

2333 os_helper.rmdir(self._dir)
2334
2335 def createMessage(self, dir, mbox=False):
2336 t = int(time.time() % 1000000)
2337 pid = self._counter
2338 self._counter += 1
2339 filename = ".".join((str(t), str(pid), "myhostname", "mydomain"))
2340 tmpname = os.path.join(self._dir, "tmp", filename)
2341 newname = os.path.join(self._dir, dir, filename)
2342 with open(tmpname, "w", encoding="utf-8") as fp:
2343 self._msgfiles.append(tmpname)
2344 if mbox:
2345 fp.write(FROM_)
2346 fp.write(DUMMY_MESSAGE)
2347 try:
2348 os.link(tmpname, newname)
2349 except (AttributeError, PermissionError):
2350 with open(newname, "w") as fp:
2351 fp.write(DUMMY_MESSAGE)
2352 self._msgfiles.append(newname)
2353 return tmpname
2354
2355 def test_empty_maildir(self):
2356 """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