From 1689804877ca226b1d2058ae99ff0ecc9173698f Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 19 Nov 2020 10:15:36 -0500 Subject: [PATCH] Try doing some other thing in Windows --- src/allmydata/test/web/test_webish.py | 34 +++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/allmydata/test/web/test_webish.py b/src/allmydata/test/web/test_webish.py index a510f26f2..a4ccbc7b9 100644 --- a/src/allmydata/test/web/test_webish.py +++ b/src/allmydata/test/web/test_webish.py @@ -26,8 +26,12 @@ from testtools.matchers import ( MatchesAll, Not, IsInstance, + HasLength, ) +from twisted.python.runtime import ( + platform, +) from twisted.python.filepath import ( FilePath, ) @@ -244,19 +248,29 @@ class TahoeLAFSSiteTests(SyncTestCase): # Another approach is to make the temp directory unwriteable and # observe the failure when an attempt is made to create a file there. # This is hardly a lovely solution but at least it's kind of simple. - tempdir.chmod(0o400) - with self.assertRaises(OSError) as ctx: + # + # It would be nice if it worked consistently cross-platform but on + # Windows os.chmod is more or less broken. + if platform.isWindows(): request.gotLength(request_body_size) - raise Exception( - "OSError not raised, instead tempdir.children() = {}".format( - tempdir.children(), - ), + self.assertThat( + tempdir.children(), + HasLength(1), ) + else: + tempdir.chmod(0o550) + with self.assertRaises(OSError) as ctx: + request.gotLength(request_body_size) + raise Exception( + "OSError not raised, instead tempdir.children() = {}".format( + tempdir.children(), + ), + ) - self.assertThat( - ctx.exception.errno, - Equals(EACCES), - ) + self.assertThat( + ctx.exception.errno, + Equals(EACCES), + ) def test_unknown_request_size(self): """