Skip to content
Snippets Groups Projects
Commit 279388e3 authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Skip unwritable dir/file checks on Windows

On Windows Python just hangs because of a misinterpretation of the
returned error. See https://bugs.python.org/issue22107
parent ca4e3ffa
No related branches found
No related tags found
No related merge requests found
import contextlib import contextlib
import platform
import tempfile import tempfile
from pathlib import Path from pathlib import Path
from unittest import mock from unittest import mock
...@@ -11,12 +12,20 @@ from tests.test_worker import AbstractFWorkerTest ...@@ -11,12 +12,20 @@ from tests.test_worker import AbstractFWorkerTest
@mock.patch('socket.gethostname', new=lambda: 'ws-unittest') @mock.patch('socket.gethostname', new=lambda: 'ws-unittest')
class PretaskWriteCheckTest(AbstractFWorkerTest): class PretaskWriteCheckTest(AbstractFWorkerTest):
def test_not_writable_dir(self): def test_not_writable_dir(self):
if platform.system() == 'Windows':
# Skip because of https://bugs.python.org/issue22107
return
with self.write_check() as tdir: with self.write_check() as tdir:
unwritable_dir = tdir / 'unwritable' unwritable_dir = tdir / 'unwritable'
unwritable_dir.mkdir(0o555) unwritable_dir.mkdir(0o555)
self.worker.pretask_check_params.pre_task_check_write = (unwritable_dir, ) self.worker.pretask_check_params.pre_task_check_write = (unwritable_dir, )
def test_not_writable_file(self): def test_not_writable_file(self):
if platform.system() == 'Windows':
# Skip because of https://bugs.python.org/issue22107
return
with self.write_check() as tdir: with self.write_check() as tdir:
unwritable_dir = tdir / 'unwritable' unwritable_dir = tdir / 'unwritable'
unwritable_dir.mkdir(0o555) unwritable_dir.mkdir(0o555)
...@@ -99,6 +108,10 @@ class PretaskWriteCheckTest(AbstractFWorkerTest): ...@@ -99,6 +108,10 @@ class PretaskWriteCheckTest(AbstractFWorkerTest):
@mock.patch('socket.gethostname', new=lambda: 'ws-unittest') @mock.patch('socket.gethostname', new=lambda: 'ws-unittest')
class PretaskReadCheckTest(AbstractFWorkerTest): class PretaskReadCheckTest(AbstractFWorkerTest):
def test_not_readable_dir(self): def test_not_readable_dir(self):
if platform.system() == 'Windows':
# Skip because of https://bugs.python.org/issue22107
return
def cleanup(): def cleanup():
unreadable_dir.chmod(0o755) unreadable_dir.chmod(0o755)
...@@ -108,6 +121,10 @@ class PretaskReadCheckTest(AbstractFWorkerTest): ...@@ -108,6 +121,10 @@ class PretaskReadCheckTest(AbstractFWorkerTest):
self.worker.pretask_check_params.pre_task_check_read = (unreadable_dir, ) self.worker.pretask_check_params.pre_task_check_read = (unreadable_dir, )
def test_read_file_exists(self): def test_read_file_exists(self):
if platform.system() == 'Windows':
# Skip because of https://bugs.python.org/issue22107
return
def post_run(): def post_run():
self.assertTrue(existing.exists(), '%s should not have been deleted' % existing) self.assertTrue(existing.exists(), '%s should not have been deleted' % existing)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment