-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`HistoricalRecords.context` was added in favor of it a few years ago, and since it has always been undocumented, it's time to properly deprecate it. 4.0 would have been the natural version to remove it if it were documented as part of the publicly exposed API, but since it's not, 3.10 seems like a reasonable choice. Also removed importing `threading.local` in case `asgiref.local.Local` is not available, as the latter should always be installed now that all our supported Django versions use it as a requirement.
- Loading branch information
Showing
3 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
import unittest | ||
|
||
from simple_history import __version__ | ||
from simple_history.models import HistoricalRecords | ||
from simple_history.templatetags.simple_history_admin_list import display_list | ||
|
||
|
||
class DeprecationWarningTest(unittest.TestCase): | ||
def test__display_list__warns_deprecation_and_is_yet_to_be_removed(self): | ||
def test__display_list__warns_deprecation(self): | ||
with self.assertWarns(DeprecationWarning): | ||
display_list({}) | ||
# DEV: `display_list()` (and the file `simple_history_admin_list.py`) should be | ||
# removed when 3.8 is released | ||
self.assertLess(__version__, "3.8") | ||
|
||
def test__HistoricalRecords_thread__warns_deprecation(self): | ||
with self.assertWarns(DeprecationWarning): | ||
context = HistoricalRecords.thread | ||
self.assertIs(context, HistoricalRecords.context) | ||
with self.assertWarns(DeprecationWarning): | ||
context = getattr(HistoricalRecords, "thread") | ||
self.assertIs(context, HistoricalRecords.context) | ||
with self.assertWarns(DeprecationWarning): | ||
context = HistoricalRecords().thread | ||
self.assertIs(context, HistoricalRecords.context) | ||
with self.assertWarns(DeprecationWarning): | ||
context = getattr(HistoricalRecords(), "thread") | ||
self.assertIs(context, HistoricalRecords.context) | ||
|
||
# DEV: `_DeprecatedThreadDescriptor` and the `thread` attribute of | ||
# `HistoricalRecords` should be removed when 3.10 is released | ||
self.assertLess(__version__, "3.10") |