From cf915cb5138e0b245393429e141cb741a390a095 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Thu, 15 Nov 2018 17:38:47 +0100 Subject: [PATCH] Added a test for a lookup in Model.refresh_from_db(fields=[...]). --- tests/basic/tests.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/basic/tests.py b/tests/basic/tests.py index 342c39ea34..b3bb4d02cc 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -649,6 +649,12 @@ class ModelRefreshTests(TestCase): with self.assertRaisesMessage(TypeError, msg): s.refresh_from_db(unknown_kwarg=10) + def test_lookup_in_fields(self): + s = SelfRef.objects.create() + msg = 'Found "__" in fields argument. Relations and transforms are not allowed in fields.' + with self.assertRaisesMessage(ValueError, msg): + s.refresh_from_db(fields=['foo__bar']) + def test_refresh_fk(self): s1 = SelfRef.objects.create() s2 = SelfRef.objects.create()