The user_with_custom_thresholds fixture used UserProfile.objects.get_or_create()
which returns a separate Python instance from the one cached in
user._state.fields_cache['profile']. When the fixture modified and saved
the get_or_create instance, the cached instance on the user object still
held default values (periodic=16, full=24). compute_fasting() accessed
u.profile which returned the stale cached object.
Fixed by modifying through u.profile directly, which operates on the
same cached instance. Also applied black formatting to fasting.py.