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

Method do_create

Lib/test/test_tempfile.py:638–659  ·  view source on GitHub ↗
(self, dir=None, pre=None, suf=None)

Source from the content-addressed store, hash-verified

636 """Test mkstemp()."""
637
638 def do_create(self, dir=None, pre=None, suf=None):
639 output_type = tempfile._infer_return_type(dir, pre, suf)
640 if dir is None:
641 if output_type is str:
642 dir = tempfile.gettempdir()
643 else:
644 dir = tempfile.gettempdirb()
645 if pre is None:
646 pre = output_type()
647 if suf is None:
648 suf = output_type()
649 (fd, name) = tempfile.mkstemp(dir=dir, prefix=pre, suffix=suf)
650 (ndir, nbase) = os.path.split(name)
651 adir = os.path.abspath(dir)
652 self.assertEqual(adir, ndir,
653 "Directory '%s' incorrectly returned as '%s'" % (adir, ndir))
654
655 try:
656 self.nameCheck(name, dir, pre, suf)
657 finally:
658 os.close(fd)
659 os.unlink(name)
660
661 def test_basic(self):
662 # mkstemp can create files

Callers 3

test_basicMethod · 0.95
test_choose_directoryMethod · 0.95

Calls 6

nameCheckMethod · 0.80
splitMethod · 0.45
abspathMethod · 0.45
assertEqualMethod · 0.45
closeMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected