• Home
  • Raw
  • Download

Lines Matching refs:tempfile

2 import tempfile
23 has_textmode = (tempfile._text_openflags != tempfile._bin_openflags)
39 self.assertIs(str, tempfile._infer_return_type(''))
40 self.assertIs(bytes, tempfile._infer_return_type(b''))
41 self.assertIs(str, tempfile._infer_return_type(None))
44 self.assertIs(str, tempfile._infer_return_type('', ''))
45 self.assertIs(bytes, tempfile._infer_return_type(b'', b''))
47 tempfile._infer_return_type('', b'')
49 tempfile._infer_return_type(b'', '')
52 self.assertIs(str, tempfile._infer_return_type(None, ''))
53 self.assertIs(str, tempfile._infer_return_type('', None))
54 self.assertIs(str, tempfile._infer_return_type(None, None))
55 self.assertIs(bytes, tempfile._infer_return_type(b'', None))
56 self.assertIs(bytes, tempfile._infer_return_type(None, b''))
58 tempfile._infer_return_type('', None, b'')
60 tempfile._infer_return_type(b'', None, '')
63 self.assertIs(str, tempfile._infer_return_type(pathlib.Path('/')))
73 self.assertIs(str, tempfile._infer_return_type(Path('/')))
74 self.assertIs(bytes, tempfile._infer_return_type(Path(b'/')))
75 self.assertIs(str, tempfile._infer_return_type('', Path('')))
76 self.assertIs(bytes, tempfile._infer_return_type(b'', Path(b'')))
77 self.assertIs(bytes, tempfile._infer_return_type(None, Path(b'')))
78 self.assertIs(str, tempfile._infer_return_type(None, Path('')))
81 tempfile._infer_return_type('', Path(b''))
83 tempfile._infer_return_type(b'', Path(''))
141 dict = tempfile.__dict__
172 self.r = tempfile._RandomNameSequence()
238 cand = tempfile._candidate_tempdir_list()
254 cand = tempfile._candidate_tempdir_list()
279 with tempfile.TemporaryDirectory() as our_temp_directory:
284 with support.swap_attr(tempfile, "_candidate_tempdir_list",
287 tempfile._get_default_tempdir()
296 tempfile._get_default_tempdir()
307 tempfile._get_default_tempdir()
316 obj = tempfile._get_candidate_names()
317 self.assertIsInstance(obj, tempfile._RandomNameSequence)
321 a = tempfile._get_candidate_names()
322 b = tempfile._get_candidate_names()
329 dir = tempfile.mkdtemp()
331 with support.swap_attr(tempfile, 'tempdir', dir):
338 return support.swap_attr(tempfile,
347 oldmode = mode = os.stat(tempfile.tempdir).st_mode
349 os.chmod(tempfile.tempdir, mode)
351 if os.access(tempfile.tempdir, os.W_OK):
355 self.assertEqual(os.listdir(tempfile.tempdir), [])
357 os.chmod(tempfile.tempdir, oldmode)
361 tempdir = os.path.join(tempfile.tempdir, 'nonexistent')
362 with support.swap_attr(tempfile, 'tempdir', tempdir):
368 tempdir = os.path.join(tempfile.tempdir, 'file')
370 with support.swap_attr(tempfile, 'tempdir', tempdir):
379 _bflags = tempfile._bin_openflags
380 _tflags = tempfile._text_openflags
388 output_type = tempfile._infer_return_type(dir, pre, suf)
389 (self.fd, self.name) = tempfile._mkstemp_inner(dir, pre, suf, flags, output_type)
399 output_type = tempfile._infer_return_type(dir, pre, suf)
402 dir = tempfile.gettempdir()
404 dir = tempfile.gettempdirb()
425 dir_b = tempfile.gettempdirb()
447 dir = tempfile.mkdtemp()
518 return tempfile._mkstemp_inner(tempfile.gettempdir(),
519 tempfile.gettempprefix(),
521 tempfile._bin_openflags,
542 dir = tempfile.mkdtemp()
555 p = tempfile.gettempprefix()
560 pb = tempfile.gettempprefixb()
571 p = tempfile.gettempprefix() + "xxxxxx.xxx"
572 d = tempfile.mkdtemp(prefix="")
588 for d in (tempfile.gettempdir(), tempfile.gettempdirb()):
600 with tempfile.NamedTemporaryFile() as file:
605 a = tempfile.gettempdir()
606 b = tempfile.gettempdir()
607 c = tempfile.gettempdirb()
616 case_sensitive_tempdir = tempfile.mkdtemp("-Temp")
617 _tempdir, tempfile.tempdir = tempfile.tempdir, None
622 self.assertEqual(tempfile.gettempdir(), case_sensitive_tempdir)
624 tempfile.tempdir = _tempdir
632 output_type = tempfile._infer_return_type(dir, pre, suf)
635 dir = tempfile.gettempdir()
637 dir = tempfile.gettempdirb()
642 (fd, name) = tempfile.mkstemp(dir=dir, prefix=pre, suffix=suf)
666 d = tempfile.gettempdirb()
683 dir = tempfile.mkdtemp()
691 orig_tempdir = tempfile.tempdir
692 self.assertIsInstance(tempfile.tempdir, (str, type(None)))
694 fd, path = tempfile.mkstemp()
698 tempfile.tempdir = tempfile.gettempdirb()
699 self.assertIsInstance(tempfile.tempdir, bytes)
700 self.assertIsInstance(tempfile.gettempdir(), str)
701 self.assertIsInstance(tempfile.gettempdirb(), bytes)
702 fd, path = tempfile.mkstemp()
706 fd, path = tempfile.mkstemp(suffix='.txt')
710 fd, path = tempfile.mkstemp(prefix='test-temp-')
714 fd, path = tempfile.mkstemp(dir=tempfile.gettempdir())
719 tempfile.tempdir = orig_tempdir
726 return tempfile.mkdtemp()
729 output_type = tempfile._infer_return_type(dir, pre, suf)
732 dir = tempfile.gettempdir()
734 dir = tempfile.gettempdirb()
739 name = tempfile.mkdtemp(dir=dir, prefix=pre, suffix=suf)
758 d = tempfile.gettempdirb()
784 dir = tempfile.mkdtemp()
813 file = tempfile.NamedTemporaryFile(delete=False)
816 dir = tempfile.mkdtemp()
824 dir1 = tempfile.mkdtemp()
826 dir2 = tempfile.mkdtemp()
830 orig_tempdir = tempfile.tempdir
831 self.assertIsInstance(tempfile.tempdir, (str, type(None)))
833 path = tempfile.mkdtemp()
836 tempfile.tempdir = tempfile.gettempdirb()
837 self.assertIsInstance(tempfile.tempdir, bytes)
838 self.assertIsInstance(tempfile.gettempdir(), str)
839 self.assertIsInstance(tempfile.gettempdirb(), bytes)
840 path = tempfile.mkdtemp()
843 path = tempfile.mkdtemp(suffix='-dir')
846 path = tempfile.mkdtemp(prefix='test-mkdtemp-')
849 path = tempfile.mkdtemp(dir=tempfile.gettempdir())
853 tempfile.tempdir = orig_tempdir
862 self.dir = tempfile.mkdtemp()
873 _bflags = tempfile._bin_openflags
876 self.name = tempfile.mktemp(dir=dir, prefix=pre, suffix=suf)
923 dir = tempfile.gettempdir()
924 file = tempfile.NamedTemporaryFile(dir=dir, prefix=pre, suffix=suf,
960 f = tempfile.NamedTemporaryFile(mode='w+b')
970 f = tempfile.NamedTemporaryFile()
976 dir = tempfile.mkdtemp()
978 with tempfile.NamedTemporaryFile(dir=dir) as f:
987 dir = tempfile.mkdtemp()
990 f = tempfile.NamedTemporaryFile(dir=dir, delete=False)
1003 f = tempfile.NamedTemporaryFile()
1011 with tempfile.NamedTemporaryFile() as f:
1029 self.assertRaises(ValueError, tempfile.NamedTemporaryFile)
1033 dir = tempfile.mkdtemp()
1036 tempfile.NamedTemporaryFile(mode='wr', dir=dir)
1038 tempfile.NamedTemporaryFile(mode=2, dir=dir)
1048 dir = tempfile.gettempdir()
1049 file = tempfile.SpooledTemporaryFile(max_size=max_size, dir=dir, prefix=pre, suffix=suf)
1063 dir = tempfile.mkdtemp()
1065 f = tempfile.SpooledTemporaryFile(max_size=10, dir=dir)
1135 f = tempfile.SpooledTemporaryFile()
1144 f = tempfile.SpooledTemporaryFile(max_size=1)
1166 f = tempfile.SpooledTemporaryFile(max_size=10)
1192 f = tempfile.SpooledTemporaryFile(mode='w+', max_size=10,
1222 f = tempfile.SpooledTemporaryFile(mode='w+', max_size=10,
1249 with tempfile.SpooledTemporaryFile(max_size=1) as f:
1260 with tempfile.SpooledTemporaryFile(max_size=1) as f:
1274 f = tempfile.SpooledTemporaryFile(max_size=1)
1288 f = tempfile.SpooledTemporaryFile(max_size=10)
1295 f = tempfile.SpooledTemporaryFile(max_size=10)
1301 f = tempfile.SpooledTemporaryFile(max_size=10)
1308 self.assertIsInstance(tempfile.SpooledTemporaryFile[bytes],
1311 if tempfile.NamedTemporaryFile is not tempfile.TemporaryFile:
1319 tempfile.TemporaryFile()
1323 dir = tempfile.mkdtemp()
1324 f = tempfile.TemporaryFile(dir=dir)
1339 f = tempfile.TemporaryFile()
1349 with tempfile.TemporaryFile(*args, **kwargs) as fileobj:
1369 self.assertRaises(ValueError, tempfile.TemporaryFile)
1397 dir = tempfile.gettempdir()
1398 tmp = tempfile.TemporaryDirectory(
1420 with tempfile.TemporaryDirectory() as nonexistent:
1423 tempfile.TemporaryDirectory(dir=nonexistent)
1428 dir = tempfile.mkdtemp()
1441 with tempfile.TemporaryDirectory() as working_dir:
1584 dir = tempfile.mkdtemp()
1597 with tempfile.TemporaryDirectory() as working_dir:
1649 with tempfile.TemporaryDirectory() as working_dir: