MCPcopy
hub / github.com/giampaolo/pyftpdlib / get_testfn

Function get_testfn

tests/__init__.py:128–139  ·  view source on GitHub ↗

Return an absolute pathname of a file or dir that did not exist at the time this call is made. Also schedule it for safe deletion at interpreter exit. It's technically racy but probably not really due to the time variant.

(suffix="", dir=None)

Source from the content-addressed store, hash-verified

126
127
128def get_testfn(suffix="", dir=None):
129 """Return an absolute pathname of a file or dir that did not
130 exist at the time this call is made. Also schedule it for safe
131 deletion at interpreter exit. It's technically racy but probably
132 not really due to the time variant.
133 """
134 if dir is None:
135 dir = os.getcwd()
136 while True:
137 name = tempfile.mktemp(prefix=TESTFN_PREFIX, suffix=suffix, dir=dir)
138 if not os.path.exists(name): # also include dirs
139 return os.path.basename(name)
140
141
142def safe_rmpath(path):

Callers 1

get_testfnMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected