From 9141da1a80d81b4605594af0a7930b5b011c8e29 Mon Sep 17 00:00:00 2001 From: Martijn Jacobs Date: Wed, 24 Apr 2019 11:46:55 +0200 Subject: [PATCH] Fixed #30366 -- Skipped StatReloaderTests on HFS+ filesystems. When on MacOS High Sierra or below (<=10.13) it could be that a HFS+ filesystem is used. HFS+ has a time resolution of only one second which can be too low for some of the tests. --- tests/utils_tests/test_autoreload.py | 5 ++++- tests/utils_tests/utils.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/utils_tests/utils.py diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py index 1f3bc0c95b1..fdfb47797ee 100644 --- a/tests/utils_tests/test_autoreload.py +++ b/tests/utils_tests/test_autoreload.py @@ -11,7 +11,7 @@ import weakref import zipfile from importlib import import_module from pathlib import Path -from unittest import mock, skip +from unittest import mock, skip, skipIf from django.apps.registry import Apps from django.test import SimpleTestCase @@ -19,6 +19,8 @@ from django.test.utils import extend_sys_path from django.utils import autoreload from django.utils.autoreload import WatchmanUnavailable +from .utils import on_macos_with_hfs + class TestIterModulesAndFiles(SimpleTestCase): def import_and_cleanup(self, name): @@ -637,6 +639,7 @@ class WatchmanReloaderTests(ReloaderTests, IntegrationTests): self.assertIsInstance(mocked_server_status.call_args[0][0], TestException) +@skipIf(on_macos_with_hfs(), "These tests do not work with HFS+ as a filesystem") class StatReloaderTests(ReloaderTests, IntegrationTests): RELOADER_CLS = autoreload.StatReloader diff --git a/tests/utils_tests/utils.py b/tests/utils_tests/utils.py new file mode 100644 index 00000000000..2aa207287a9 --- /dev/null +++ b/tests/utils_tests/utils.py @@ -0,0 +1,14 @@ +import platform + + +def on_macos_with_hfs(): + """ + MacOS 10.13 (High Sierra) and lower can use HFS+ as a filesystem. + HFS+ has a time resolution of only one second which can be too low for + some of the tests. + """ + macos_version = platform.mac_ver()[0] + if macos_version != '': + parsed_macos_version = tuple(int(x) for x in macos_version.split('.')) + return parsed_macos_version < (10, 14) + return False