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

Method _setup_test

Lib/test/test_tarfile.py:3223–3241  ·  view source on GitHub ↗
(mock_geteuid)

Source from the content-addressed store, hash-verified

3221 @staticmethod
3222 @contextmanager
3223 def _setup_test(mock_geteuid):
3224 mock_geteuid.return_value = 0 # lie and say we're root
3225 fname = 'numeric-owner-testfile'
3226 dirname = 'dir'
3227
3228 # the names we want stored in the tarfile
3229 filename_1 = fname
3230 dirname_1 = dirname
3231 filename_2 = os.path.join(dirname, fname)
3232
3233 # create the tarfile with the contents we're after
3234 tar_filename = NumericOwnerTest._make_test_archive(filename_1,
3235 dirname_1,
3236 filename_2)
3237
3238 # open the tarfile for reading. yield it and the names of the items
3239 # we stored into the file
3240 with tarfile.open(tar_filename) as tarfl:
3241 yield tarfl, filename_1, dirname_1, filename_2
3242
3243 @unittest.mock.patch('os.chown')
3244 @unittest.mock.patch('os.chmod')

Calls 3

_make_test_archiveMethod · 0.80
joinMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected