diff --git a/python/GafferImageTest/CatalogueTest.py b/python/GafferImageTest/CatalogueTest.py index 01c791d0ac2..e16e7b970b0 100644 --- a/python/GafferImageTest/CatalogueTest.py +++ b/python/GafferImageTest/CatalogueTest.py @@ -41,6 +41,7 @@ import imath import pathlib import unittest +import subprocess import IECore @@ -615,13 +616,15 @@ def testDeleteBeforeSaveCompletesWithScriptVariables( self ) : self.assertEqual( len( list( baseDirectory.glob( "*" ) ) ), 0 ) - @unittest.skipIf( os.name == "nt", "Windows allows new files in read-only directories" ) def testNonWritableDirectory( self ) : s = Gaffer.ScriptNode() s["c"] = GafferImage.Catalogue() s["c"]["directory"].setValue( self.temporaryDirectory() / "catalogue" ) - os.chmod( self.temporaryDirectory(), stat.S_IREAD ) + if os.name != "nt" : + os.chmod( self.temporaryDirectory(), stat.S_IREAD ) + else : + subprocess.check_call( [ "icacls", self.temporaryDirectory(), "/deny", "Users:(OI)(CI)(W)" ] ) r = GafferImage.ImageReader() r["fileName"].setValue( self.imagesPath() / "blurRange.exr" ) @@ -637,9 +640,17 @@ def testNonWritableDirectory( self ) : self.assertEqual( len( mh.messages ), 1 ) self.assertEqual( mh.messages[0].level, IECore.Msg.Level.Error ) - self.assertIn( "Permission denied", mh.messages[0].message ) + self.assertIn( + "Permission denied" if os.name != "nt" else "Access is denied", + mh.messages[0].message + ) - with self.assertRaisesRegex( RuntimeError, r".* : Could not open \".*\" \(Permission denied\)" ) : + with self.assertRaisesRegex( + RuntimeError, + r".* : Could not open \".*\" " + ( + "\(Permission denied\)" if os.name != "nt" else "\(No such file or directory\)" + ) + ) : GafferImage.ImageAlgo.image( s["c"]["out"] ) def testDeleteKeepsOrder( self ) :