1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00
django/tests/model_fields/test_filepathfield.py

23 lines
623 B
Python

import os
from django.db.models import FilePathField
from django.test import SimpleTestCase
class FilePathFieldTests(SimpleTestCase):
def test_path(self):
path = os.path.dirname(__file__)
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)