MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetTempDir

Function GetTempDir

tensorflow/python/platform/googletest.py:68–93  ·  view source on GitHub ↗

Return a temporary directory for tests to use.

()

Source from the content-addressed store, hash-verified

66
67
68def GetTempDir():
69 """Return a temporary directory for tests to use."""
70 global _googletest_temp_dir
71 if not _googletest_temp_dir:
72 if os.environ.get('TEST_TMPDIR'):
73 temp_dir = tempfile.mkdtemp(prefix=os.environ['TEST_TMPDIR'])
74 else:
75 first_frame = tf_inspect.stack()[-1][0]
76 temp_dir = os.path.join(tempfile.gettempdir(),
77 os.path.basename(tf_inspect.getfile(first_frame)))
78 temp_dir = tempfile.mkdtemp(prefix=temp_dir.rstrip('.py'))
79
80 # Make sure we have the correct path separators.
81 temp_dir = temp_dir.replace('/', os.sep)
82
83 def delete_temp_dir(dirname=temp_dir):
84 try:
85 file_io.delete_recursively(dirname)
86 except errors.OpError as e:
87 logging.error('Error removing %s: %s', dirname, e)
88
89 atexit.register(delete_temp_dir)
90
91 _googletest_temp_dir = temp_dir
92
93 return _googletest_temp_dir
94
95
96def test_src_dir_path(relative_path):

Callers

nothing calls this directly

Calls 6

mkdtempMethod · 0.80
replaceMethod · 0.80
getMethod · 0.45
stackMethod · 0.45
joinMethod · 0.45
registerMethod · 0.45

Tested by

no test coverage detected