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

Method _make_test_archive

Lib/test/test_tarfile.py:3198–3219  ·  view source on GitHub ↗
(filename_1, dirname_1, filename_2)

Source from the content-addressed store, hash-verified

3196
3197 @staticmethod
3198 def _make_test_archive(filename_1, dirname_1, filename_2):
3199 # the file contents to write
3200 fobj = io.BytesIO(b"content")
3201
3202 # create a tar file with a file, a directory, and a file within that
3203 # directory. Assign various .uid/.gid values to them
3204 items = [(filename_1, 99, 98, tarfile.REGTYPE, fobj),
3205 (dirname_1, 77, 76, tarfile.DIRTYPE, None),
3206 (filename_2, 88, 87, tarfile.REGTYPE, fobj),
3207 ]
3208 with tarfile.open(tmpname, 'w') as tarfl:
3209 for name, uid, gid, typ, contents in items:
3210 t = tarfile.TarInfo(name)
3211 t.uid = uid
3212 t.gid = gid
3213 t.uname = 'root'
3214 t.gname = 'root'
3215 t.type = typ
3216 tarfl.addfile(t, contents)
3217
3218 # return the full pathname to the tar file
3219 return tmpname
3220
3221 @staticmethod
3222 @contextmanager

Callers 1

_setup_testMethod · 0.80

Calls 2

addfileMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected