From af02593ebde7457d8c01f7f7b5c48265203a7ac1 Mon Sep 17 00:00:00 2001 From: Swen Kooij Date: Sat, 31 Mar 2018 08:52:12 +0300 Subject: [PATCH] Add test to make sure LocalizedValue doesn't cast values to string --- tests/test_value.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_value.py b/tests/test_value.py index 844bac0..10b4674 100644 --- a/tests/test_value.py +++ b/tests/test_value.py @@ -1,6 +1,7 @@ from django.conf import settings from django.test import TestCase from django.utils import translation +from django.db.models import F from localized_fields.value import LocalizedValue @@ -180,3 +181,11 @@ class LocalizedValueTestCase(TestCase): value = LocalizedValue('beer') assert value.get(settings.LANGUAGE_CODE) == 'beer' + + @staticmethod + def test_construct_expression(): + """Tests whether passing expressions as values + works properly and are not converted to string.""" + + value = LocalizedValue(dict(en=F('other'))) + assert isinstance(value.en, F)