2017-07-06 17:18:05 +00:00
|
|
|
from django.test import TestCase
|
2018-04-27 21:18:15 +00:00
|
|
|
from django.utils.deprecation import RemovedInDjango30Warning
|
2017-07-06 17:18:05 +00:00
|
|
|
|
|
|
|
from .models import Cash, CashModelDeprecated
|
|
|
|
|
|
|
|
|
|
|
|
class FromDBValueDeprecationTests(TestCase):
|
|
|
|
|
|
|
|
def test_deprecation(self):
|
2018-04-27 21:18:15 +00:00
|
|
|
msg = (
|
2017-07-06 17:18:05 +00:00
|
|
|
'Remove the context parameter from CashFieldDeprecated.from_db_value(). '
|
|
|
|
'Support for it will be removed in Django 3.0.'
|
|
|
|
)
|
2018-04-27 21:18:15 +00:00
|
|
|
CashModelDeprecated.objects.create(cash='12.50')
|
|
|
|
with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
|
|
|
|
instance = CashModelDeprecated.objects.get()
|
|
|
|
self.assertIsInstance(instance.cash, Cash)
|