Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed FilePathField tests to use it's own directory with test files.

In previous version it used /django/forms/ which was fragile - for some
users .pyc files were not generated and this tests failed.
  • Loading branch information...
commit a89034a2d8c0ca84184d260090d87645cfdc0e7d 1 parent 71d9a2a
@HonzaKral HonzaKral authored
View
29 tests/regressiontests/forms/tests/fields.py
@@ -985,12 +985,11 @@ def test_filepathfield_4(self):
self.assertTrue(got[0].endswith(exp[0]))
def test_filepathfield_folders(self):
- path = forms.__file__
- path = os.path.dirname(path) + '/'
+ path = os.path.dirname(__file__) + '/filepath_test_files/'
f = FilePathField(path=path, allow_folders=True, allow_files=False)
f.choices.sort()
expected = [
- ('/django/forms/extras', 'extras'),
+ ('/tests/regressiontests/forms/tests/filepath_test_files/directory', 'directory'),
]
for exp, got in zip(expected, fix_os_paths(f.choices)):
self.assertEqual(exp[1], got[1])
@@ -999,23 +998,15 @@ def test_filepathfield_folders(self):
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')
+ ('/tests/regressiontests/forms/tests/filepath_test_files/.dot-file', '.dot-file'),
+ ('/tests/regressiontests/forms/tests/filepath_test_files/directory', 'directory'),
+ ('/tests/regressiontests/forms/tests/filepath_test_files/fake-image.jpg', 'fake-image.jpg'),
+ ('/tests/regressiontests/forms/tests/filepath_test_files/real-text-file.txt', 'real-text-file.txt'),
]
- for exp, got in zip(expected, fix_os_paths(f.choices)):
+
+ actual = fix_os_paths(f.choices)
+ self.assertEqual(len(expected), len(actual))
+ for exp, got in zip(expected, actual):
self.assertEqual(exp[1], got[1])
self.assertTrue(got[0].endswith(exp[0]))
View
0  tests/regressiontests/forms/tests/filepath_test_files/.dot-file
No changes.
View
0  tests/regressiontests/forms/tests/filepath_test_files/directory/.keep
No changes.
View
0  tests/regressiontests/forms/tests/filepath_test_files/fake-image.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  tests/regressiontests/forms/tests/filepath_test_files/real-text-file.txt
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.