Skip to content

Commit cbf007b

Browse files
authored
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.
1 parent 236f733 commit cbf007b

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

Lib/test/test_tempfile.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,30 +1594,6 @@ def test_unexpected_error(self):
15941594
mock_close.assert_called()
15951595
self.assertEqual(os.listdir(dir), [])
15961596

1597-
@os_helper.skip_unless_hardlink
1598-
@unittest.skipUnless(tempfile._O_TMPFILE_WORKS, 'need os.O_TMPFILE')
1599-
@unittest.skipUnless(os.path.exists('/proc/self/fd'),
1600-
'need /proc/self/fd')
1601-
def test_link_tmpfile(self):
1602-
dir = tempfile.mkdtemp()
1603-
self.addCleanup(os_helper.rmtree, dir)
1604-
filename = os.path.join(dir, "link")
1605-
1606-
with tempfile.TemporaryFile('w', dir=dir) as tmp:
1607-
# the flag can become False on Linux <= 3.11
1608-
if not tempfile._O_TMPFILE_WORKS:
1609-
self.skipTest("O_TMPFILE doesn't work")
1610-
1611-
tmp.write("hello")
1612-
tmp.flush()
1613-
fd = tmp.fileno()
1614-
1615-
os.link(f'/proc/self/fd/{fd}',
1616-
filename,
1617-
follow_symlinks=True)
1618-
with open(filename) as fp:
1619-
self.assertEqual(fp.read(), "hello")
1620-
16211597

16221598
# Helper for test_del_on_shutdown
16231599
class NulledModules:

0 commit comments

Comments
 (0)