We cannot run test_delete_false

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:Factory/python311?expand=0&rev=106
This commit is contained in:
Matej Cepl 2024-02-29 09:21:47 +00:00 committed by Git OBS Bridge
parent 27413421cf
commit 5c654e8335

View File

@ -1,8 +1,8 @@
--- ---
Lib/tempfile.py | 16 + Lib/tempfile.py | 16 +
Lib/test/test_tempfile.py | 119 ++++++++++ Lib/test/test_tempfile.py | 113 ++++++++++
Misc/NEWS.d/next/Library/2022-12-01-16-57-44.gh-issue-91133.LKMVCV.rst | 2 Misc/NEWS.d/next/Library/2022-12-01-16-57-44.gh-issue-91133.LKMVCV.rst | 2
3 files changed, 137 insertions(+) 3 files changed, 131 insertions(+)
--- a/Lib/tempfile.py --- a/Lib/tempfile.py
+++ b/Lib/tempfile.py +++ b/Lib/tempfile.py
@ -135,12 +135,10 @@
@support.cpython_only @support.cpython_only
def test_del_on_collection(self): def test_del_on_collection(self):
# A TemporaryDirectory is deleted when garbage collected # A TemporaryDirectory is deleted when garbage collected
@@ -1861,6 +1958,22 @@ class TestTemporaryDirectory(BaseTestCas @@ -1847,6 +1944,22 @@ class TestTemporaryDirectory(BaseTestCas
finally:
os_helper.unlink(filename)
+ def check_flags(self, flags): def check_flags(self, flags):
+ # skip the test if these flags are not supported (ex: FreeBSD 13) # skip the test if these flags are not supported (ex: FreeBSD 13)
+ filename = os_helper.TESTFN + filename = os_helper.TESTFN
+ try: + try:
+ open(filename, "w").close() + open(filename, "w").close()
@ -155,22 +153,11 @@
+ finally: + finally:
+ os_helper.unlink(filename) + os_helper.unlink(filename)
+ +
@unittest.skipUnless(hasattr(os, 'chflags'), 'requires os.chflags') + def check_flags(self, flags):
def test_flags(self): + # skip the test if these flags are not supported (ex: FreeBSD 13)
flags = stat.UF_IMMUTABLE | stat.UF_NOUNLINK filename = os_helper.TESTFN
@@ -1876,6 +1989,12 @@ class TestTemporaryDirectory(BaseTestCas try:
d.cleanup() open(filename, "w").close()
self.assertFalse(os.path.exists(d.name))
+ def test_delete_false(self):
+ with tempfile.TemporaryDirectory(delete=False) as working_dir:
+ pass
+ self.assertTrue(os.path.exists(working_dir))
+ shutil.rmtree(working_dir)
+
if __name__ == "__main__":
unittest.main()
--- /dev/null --- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-12-01-16-57-44.gh-issue-91133.LKMVCV.rst +++ b/Misc/NEWS.d/next/Library/2022-12-01-16-57-44.gh-issue-91133.LKMVCV.rst
@@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@