summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2012-04-22 14:44:08 +0000
committerAlex Gaynor <alex.gaynor@gmail.com>2012-04-22 14:44:08 +0000
commit3c5ff9d703be67b43655c5a40e8ee3719ad2871b (patch)
treefd8d883bdc31239d1d47ebaccc5fae33b5051a5d /tests
parent83fc9651713edfed9c3eff52b73933eb67a46a59 (diff)
Fixed #5893 -- Added a flag to FilePathField to allow listing folders, in addition to regular files. Thank you to Brian Rosner, for encouraging me to first contribute to Django 4 years ago.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17925 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/forms/tests/fields.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/tests/fields.py b/tests/regressiontests/forms/tests/fields.py
index 6e4a5445ca..4e942a1ca7 100644
--- a/tests/regressiontests/forms/tests/fields.py
+++ b/tests/regressiontests/forms/tests/fields.py
@@ -981,6 +981,42 @@ class FieldsTests(SimpleTestCase):
self.assertEqual(exp[1], got[1])
self.assertTrue(got[0].endswith(exp[0]))
+ def test_filepathfield_folders(self):
+ path = forms.__file__
+ path = os.path.dirname(path) + '/'
+ f = FilePathField(path=path, allow_folders=True, allow_files=False)
+ f.choices.sort()
+ expected = [
+ ('/django/forms/extras', 'extras'),
+ ]
+ for exp, got in zip(expected, fix_os_paths(f.choices)):
+ self.assertEqual(exp[1], got[1])
+ self.assert_(got[0].endswith(exp[0]))
+
+ f = FilePathField(path=path, allow_folders=True, allow_files=True)
+ f.choices.sort()
+ expected = [
+ ('/django/forms/__init__.py', '__init__.py'),
+ ('/django/forms/__init__.pyc', '__init__.pyc'),
+ ('/django/forms/extras', 'extras'),
+ ('/django/forms/fields.py', 'fields.py'),
+ ('/django/forms/fields.pyc', 'fields.pyc'),
+ ('/django/forms/forms.py', 'forms.py'),
+ ('/django/forms/forms.pyc', 'forms.pyc'),
+ ('/django/forms/formsets.py', 'formsets.py'),
+ ('/django/forms/formsets.pyc', 'formsets.pyc'),
+ ('/django/forms/models.py', 'models.py'),
+ ('/django/forms/models.pyc', 'models.pyc'),
+ ('/django/forms/util.py', 'util.py'),
+ ('/django/forms/util.pyc', 'util.pyc'),
+ ('/django/forms/widgets.py', 'widgets.py'),
+ ('/django/forms/widgets.pyc', 'widgets.pyc')
+ ]
+ for exp, got in zip(expected, fix_os_paths(f.choices)):
+ self.assertEqual(exp[1], got[1])
+ self.assertEqual(exp[1], got[1])
+
+
# SplitDateTimeField ##########################################################
def test_splitdatetimefield_1(self):