Fixed #29529 -- Allowed models.fields.FilePathField to accept a callable path.

This commit is contained in:
Mykola Kokalko 2019-05-02 10:42:10 +02:00 committed by Mariusz Felisiak
parent 11971cd87c
commit ef082ebb84
4 changed files with 30 additions and 1 deletions

View file

@ -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)