mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
gh-136156: Remove tempfile test_link_tmpfile() (#136534)
It's not always possible to guarantee that the file was opened with O_TMPFILE even if tempfile._O_TMPFILE_WORKS is true.
This commit is contained in:
parent
236f733d8f
commit
cbf007beeb
1 changed files with 0 additions and 24 deletions
|
@ -1594,30 +1594,6 @@ if tempfile.NamedTemporaryFile is not tempfile.TemporaryFile:
|
|||
mock_close.assert_called()
|
||||
self.assertEqual(os.listdir(dir), [])
|
||||
|
||||
@os_helper.skip_unless_hardlink
|
||||
@unittest.skipUnless(tempfile._O_TMPFILE_WORKS, 'need os.O_TMPFILE')
|
||||
@unittest.skipUnless(os.path.exists('/proc/self/fd'),
|
||||
'need /proc/self/fd')
|
||||
def test_link_tmpfile(self):
|
||||
dir = tempfile.mkdtemp()
|
||||
self.addCleanup(os_helper.rmtree, dir)
|
||||
filename = os.path.join(dir, "link")
|
||||
|
||||
with tempfile.TemporaryFile('w', dir=dir) as tmp:
|
||||
# the flag can become False on Linux <= 3.11
|
||||
if not tempfile._O_TMPFILE_WORKS:
|
||||
self.skipTest("O_TMPFILE doesn't work")
|
||||
|
||||
tmp.write("hello")
|
||||
tmp.flush()
|
||||
fd = tmp.fileno()
|
||||
|
||||
os.link(f'/proc/self/fd/{fd}',
|
||||
filename,
|
||||
follow_symlinks=True)
|
||||
with open(filename) as fp:
|
||||
self.assertEqual(fp.read(), "hello")
|
||||
|
||||
|
||||
# Helper for test_del_on_shutdown
|
||||
class NulledModules:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue