From ab7940e8115e52a0b4be92aebe5f18136fb018c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 14 Oct 2022 15:05:25 +0400 Subject: [PATCH] tests/assert-msg-test: fix opening temporary file in GDB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Win32, the file cannot be opened a second time, it must be closed first. Signed-off-by: Marc-André Lureau --- glib/tests/assert-msg-test.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/glib/tests/assert-msg-test.py b/glib/tests/assert-msg-test.py index ca0f559c4..5e5f3fb23 100755 --- a/glib/tests/assert-msg-test.py +++ b/glib/tests/assert-msg-test.py @@ -146,12 +146,14 @@ class TestAssertMessage(unittest.TestCase): self.skipTest("GDB is not installed, skipping this test!") with tempfile.NamedTemporaryFile( - prefix="assert-msg-test-", suffix=".gdb", mode="w" + prefix="assert-msg-test-", suffix=".gdb", mode="w", delete=False ) as tmp: - tmp.write(GDB_SCRIPT) - tmp.flush() - - result = self.runGdbAssertMessage("-x", tmp.name, self.__assert_msg_test) + try: + tmp.write(GDB_SCRIPT) + tmp.close() + result = self.runGdbAssertMessage("-x", tmp.name, self.__assert_msg_test) + finally: + os.unlink(tmp.name) # Some CI environments disable ptrace (as they’re running in a # container). If so, skip the test as there’s nothing we can do.