Kaydet (Commit) 3fb718f1 authored tarafından Tim Graham's avatar Tim Graham

Eliminated the need to modify a model forms test when new test files are added.

üst 5cc28dc7
...@@ -151,7 +151,7 @@ class CustomFF(models.Model): ...@@ -151,7 +151,7 @@ class CustomFF(models.Model):
class FilePathModel(models.Model): class FilePathModel(models.Model):
path = models.FilePathField(path=os.path.dirname(__file__), match=r".*\.py$", blank=True) path = models.FilePathField(path=os.path.dirname(__file__), match='models.py', blank=True)
try: try:
......
...@@ -2328,18 +2328,14 @@ class FileAndImageFieldTests(TestCase): ...@@ -2328,18 +2328,14 @@ class FileAndImageFieldTests(TestCase):
p.image.delete(save=False) p.image.delete(save=False)
def test_file_path_field_blank(self): def test_file_path_field_blank(self):
""" """FilePathField(blank=True) includes the empty option."""
Regression test for #8842: FilePathField(blank=True)
"""
class FPForm(forms.ModelForm): class FPForm(forms.ModelForm):
class Meta: class Meta:
model = FilePathModel model = FilePathModel
fields = '__all__' fields = '__all__'
form = FPForm() form = FPForm()
names = [p[1] for p in form['path'].field.choices] self.assertEqual([name for _, name in form['path'].field.choices], ['---------', 'models.py'])
names.sort()
self.assertEqual(names, ['---------', '__init__.py', 'models.py', 'test_uuid.py', 'tests.py'])
@skipUnless(test_images, "Pillow not installed") @skipUnless(test_images, "Pillow not installed")
def test_image_field(self): def test_image_field(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment