| 1 |
import os |
| 2 |
|
| 3 |
from django.db.models import FilePathField |
| 4 |
from django.test import SimpleTestCase |
| 5 |
|
| 6 |
|
| 7 |
class FilePathFieldTests(SimpleTestCase): |
| 8 |
def test_path(self): |
| 9 |
path = os.path.dirname(__file__) |
| 10 |
field = FilePathField(path=path) |
| 11 |
self.assertEqual(field.path, path) |
| 12 |
self.assertEqual(field.formfield().path, path) |
| 13 |
|
| 14 |
def test_callable_path(self): |
| 15 |
path = os.path.dirname(__file__) |
| 16 |
|
| 17 |
def generate_path(): |
| 18 |
return path |
| 19 |
|
| 20 |
field = FilePathField(path=generate_path) |
| 21 |
self.assertEqual(field.path(), path) |
| 22 |
self.assertEqual(field.formfield().path, path) |