From 09cfcfcc00f4ed7e2ebf0ea83a0e0fdef3ac84ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 4 Sep 2026 09:42:02 +0000 Subject: [PATCH] r.kappa: Avoid reopening NamedTemporaryFile on Windows in testsuite test_file kept a NamedTemporaryFile handle open while passing its path to r.kappa as the output file. Windows rejects a second process opening a file while the creating process still holds the handle; POSIX allows it. Use grass.script.core.tempfile() to get an unopened path instead, the same fix already applied to r.mfilter's testsuite in #7878, and drop the now-unneeded @xfail_windows marker. Co-Authored-By: Claude Sonnet 5 --- raster/r.kappa/testsuite/test_r_kappa.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/raster/r.kappa/testsuite/test_r_kappa.py b/raster/r.kappa/testsuite/test_r_kappa.py index 925a8658ed6..b17745ad45d 100644 --- a/raster/r.kappa/testsuite/test_r_kappa.py +++ b/raster/r.kappa/testsuite/test_r_kappa.py @@ -11,15 +11,13 @@ import os import json from pathlib import Path -from tempfile import NamedTemporaryFile from grass.script import read_command from grass.script import decode -from grass.script.core import tempname +from grass.script.core import tempfile, tempname from grass.gunittest.case import TestCase from grass.gunittest.main import test from grass.gunittest.checkers import keyvalue_equals, diff_keyvalue -from grass.gunittest.utils import xfail_windows class MatrixCorrectnessTest(TestCase): @@ -488,19 +486,18 @@ def test_stdout(self): ), ) - @xfail_windows def test_file(self): for i in range(len(self.references)): - f = NamedTemporaryFile() + outfile = tempfile(create=False) self.runModule( "r.kappa", reference=self.references[i], classification=self.classifications[i], - output=f.name, + output=outfile, format="json", overwrite=True, ) - json_out = json.loads(f.read()) + json_out = json.loads(Path(outfile).read_text()) self.assertTrue( keyvalue_equals( self.expected_outputs[i], json_out, precision=self.precision