From ef082ebb84f00e38af4e8880d04e8365c2766d34 Mon Sep 17 00:00:00 2001 From: Mykola Kokalko Date: Thu, 2 May 2019 10:42:10 +0200 Subject: Fixed #29529 -- Allowed models.fields.FilePathField to accept a callable path. --- tests/model_fields/test_filepathfield.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/model_fields') diff --git a/tests/model_fields/test_filepathfield.py b/tests/model_fields/test_filepathfield.py index d5d43ff6f6..362d12d0db 100644 --- a/tests/model_fields/test_filepathfield.py +++ b/tests/model_fields/test_filepathfield.py @@ -10,3 +10,13 @@ class FilePathFieldTests(SimpleTestCase): field = FilePathField(path=path) self.assertEqual(field.path, path) self.assertEqual(field.formfield().path, path) + + def test_callable_path(self): + path = os.path.dirname(__file__) + + def generate_path(): + return path + + field = FilePathField(path=generate_path) + self.assertEqual(field.path(), path) + self.assertEqual(field.formfield().path, path) -- cgit v1.3