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