diff options
author | Tim Graham <timograham@gmail.com> | 2018-02-28 10:24:19 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-02-28 10:26:26 -0500 |
commit | 3fb718f17d0684a2eabcf4af722e84ac4608c76f (patch) | |
tree | 9040083482a03d19f42e2fc6fc0c6647d0077517 /tests/model_forms | |
parent | 5cc28dc752c3ae78456bb835c3ba195489fc26d7 (diff) | |
download | django-3fb718f17d0684a2eabcf4af722e84ac4608c76f.tar.gz |
Eliminated the need to modify a model forms test when new test files are added.
Diffstat (limited to 'tests/model_forms')
-rw-r--r-- | tests/model_forms/models.py | 2 | ||||
-rw-r--r-- | tests/model_forms/tests.py | 8 |
2 files changed, 3 insertions, 7 deletions
diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py index aecbeb18f3..da4f5391c5 100644 --- a/tests/model_forms/models.py +++ b/tests/model_forms/models.py @@ -151,7 +151,7 @@ class CustomFF(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: diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 406a137d80..9b991d209d 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -2328,18 +2328,14 @@ class FileAndImageFieldTests(TestCase): p.image.delete(save=False) def test_file_path_field_blank(self): - """ - Regression test for #8842: FilePathField(blank=True) - """ + """FilePathField(blank=True) includes the empty option.""" class FPForm(forms.ModelForm): class Meta: model = FilePathModel fields = '__all__' form = FPForm() - names = [p[1] for p in form['path'].field.choices] - names.sort() - self.assertEqual(names, ['---------', '__init__.py', 'models.py', 'test_uuid.py', 'tests.py']) + self.assertEqual([name for _, name in form['path'].field.choices], ['---------', 'models.py']) @skipUnless(test_images, "Pillow not installed") def test_image_field(self): |