From 3493ccf2d21398bb0bb9f995e6a37c88ae95867b Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Mon, 17 Dec 2018 17:41:29 -0500 Subject: [PATCH] Skip tests the mock open on old versions of mock library Signed-off-by: Cleber Rosa --- selftests/unit/test_utils_disk.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/selftests/unit/test_utils_disk.py b/selftests/unit/test_utils_disk.py index 60e75a6f..c634bc45 100644 --- a/selftests/unit/test_utils_disk.py +++ b/selftests/unit/test_utils_disk.py @@ -6,7 +6,7 @@ try: except ImportError: import mock - +from .. import recent_mock from avocado.utils import disk from avocado.utils import process @@ -66,6 +66,8 @@ class Disk(unittest.TestCase): return_value=mock_result): self.assertEqual(disk.get_disks(), ['/dev/vda']) + @unittest.skipUnless(recent_mock(), + "mock library version cannot (easily) patch open()") def test_get_filesystems(self): expected_fs = ['dax', 'bpf', 'pipefs', 'hugetlbfs', 'devpts', 'ext3'] open_mocked = mock.mock_open(read_data=PROC_FILESYSTEMS) @@ -73,11 +75,15 @@ class Disk(unittest.TestCase): self.assertEqual(sorted(expected_fs), sorted(disk.get_available_filesystems())) + @unittest.skipUnless(recent_mock(), + "mock library version cannot (easily) patch open()") def test_get_filesystem_type_default_root(self): open_mocked = mock.mock_open(read_data=PROC_MOUNTS) with mock.patch(self.builtin_open, open_mocked): self.assertEqual('ext4', disk.get_filesystem_type()) + @unittest.skipUnless(recent_mock(), + "mock library version cannot (easily) patch open()") def test_get_filesystem_type(self): open_mocked = mock.mock_open(read_data=PROC_MOUNTS) with mock.patch(self.builtin_open, open_mocked): -- GitLab