HFS+ has the unfortunate disadvantage of having a timestamp resolution of
1 second.
In the {{{StatReloaderTests}}} class the reloader sleep time is set to
0.01 seconds to speed up the tests:
{{{#!python
class StatReloaderTests(ReloaderTests, IntegrationTests):
RELOADER_CLS = autoreload.StatReloader
def setUp(self):
super().setUp()
# Shorten the sleep time to speed up tests.
self.reloader.SLEEP_TIME = 0.01
}}}
This will result that these tests will fail when using HFS+ as a
filesystem because it won't detect that files have been created or
changed:
{{{
======================================================================
FAIL: test_glob_non_existing_directory
(utils_tests.test_autoreload.StatReloaderTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 59, in testPartExecutor
yield
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 615, in run
testMethod()
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/mock.py",
line 1195, in patched
return func(*args, **keywargs)
File
"/Users/martijn/Dev/oss/django/tests/utils_tests/test_autoreload.py", line
418, in test_glob_non_existing_directory
self.assertEqual(notify_mock.call_count, 1)
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 839, in assertEqual
assertion_func(first, second, msg=msg)
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 832, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: 0 != 1
======================================================================
FAIL: test_nonexistent_file
(utils_tests.test_autoreload.StatReloaderTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 59, in testPartExecutor
yield
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 615, in run
testMethod()
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/mock.py",
line 1195, in patched
return func(*args, **keywargs)
File
"/Users/martijn/Dev/oss/django/tests/utils_tests/test_autoreload.py", line
384, in test_nonexistent_file
self.assertEqual(notify_mock.call_count, 1)
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 839, in assertEqual
assertion_func(first, second, msg=msg)
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 832, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: 0 != 1
======================================================================
FAIL: test_nonexistent_file_in_non_existing_directory
(utils_tests.test_autoreload.StatReloaderTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 59, in testPartExecutor
yield
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 615, in run
testMethod()
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/mock.py",
line 1195, in patched
return func(*args, **keywargs)
File
"/Users/martijn/Dev/oss/django/tests/utils_tests/test_autoreload.py", line
395, in test_nonexistent_file_in_non_existing_directory
self.assertEqual(notify_mock.call_count, 1)
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 839, in assertEqual
assertion_func(first, second, msg=msg)
File
"/Users/martijn/.pyenv/versions/3.7.2/lib/python3.7/unittest/case.py",
line 832, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: 0 != 1
----------------------------------------------------------------------
}}}
How to reproduce:
{{{
./runtests.py utils_tests.test_autoreload
}}}
on a Mac OSX computer which (still) uses HFS+
--
Ticket URL: <https://code.djangoproject.com/ticket/30366>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: Martijn Jacobs (added)
* owner: nobody => Martijn Jacobs
--
Ticket URL: <https://code.djangoproject.com/ticket/30366#comment:1>
* has_patch: 0 => 1
Comment:
A possible solution can be found in the pull request here:
https://github.com/django/django/pull/11228
--
Ticket URL: <https://code.djangoproject.com/ticket/30366#comment:2>
* type: Uncategorized => Bug
* stage: Unreviewed => Ready for checkin
Comment:
After discussion on the PR, we'll got for skipping the few tests on
earlier versions of macOS. Ready to go I think.
--
Ticket URL: <https://code.djangoproject.com/ticket/30366#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"9141da1a80d81b4605594af0a7930b5b011c8e29" 9141da1a]:
{{{
#!CommitTicketReference repository=""
revision="9141da1a80d81b4605594af0a7930b5b011c8e29"
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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30366#comment:4>