Fix NullBooleanField deprecations in test suite
Supersedes #7432.
Merged the field behavior tests for NullBooleanField and nullable BooleanField, as NullBooleanField no longer has a distinct implementation. Added separate tests for the deprecation warning and disallowed allow_null argument.
How about something like this?
class TestNullBooleanField(TestCase):
@pytest.mark.filterwarnings('ignore::rest_framework.RemovedInDRF314Warning')
def test_allow_null(self):
msg = '`allow_null` is not a valid option.'
with self.assertRaisesMessage(AssertionError, msg):
serializers.NullBooleanField(allow_null=False)
def test_deprecation_warning(self):
msg = "The `NullBooleanField` is deprecated" # require full msg?
with self.assertWarnsMessage(rest_framework.RemovedInDRF314Warning, msg):
serializers.NullBooleanField()
Could also use the two assert....Message from pytest-django rather than subclassing from TestCase. 🤔
How have I never heard of assertWarns and assertWarnsMessage?? 😄 ✨
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
it is safe to close this now