﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30366	The StatReloaderTests will fail on Mac OSX when HFS+ is used as a filesystem	Martijn Jacobs	Martijn Jacobs	"HFS+ is the default filesystem for Mac OSX Sierra (10.12.x) and below before it was replaced with APFS in High Sierra (10.13.x) and above.

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+

"	Bug	closed	Testing framework	dev	Normal	fixed	HFS+ OSX Testing	Martijn Jacobs	Ready for checkin	1	0	0	0	0	0
