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.
This commit is contained in:
parent
71d9a2a7fe
commit
a89034a2d8
|
@ -985,12 +985,11 @@ class FieldsTests(SimpleTestCase):
|
||||||
self.assertTrue(got[0].endswith(exp[0]))
|
self.assertTrue(got[0].endswith(exp[0]))
|
||||||
|
|
||||||
def test_filepathfield_folders(self):
|
def test_filepathfield_folders(self):
|
||||||
path = forms.__file__
|
path = os.path.dirname(__file__) + '/filepath_test_files/'
|
||||||
path = os.path.dirname(path) + '/'
|
|
||||||
f = FilePathField(path=path, allow_folders=True, allow_files=False)
|
f = FilePathField(path=path, allow_folders=True, allow_files=False)
|
||||||
f.choices.sort()
|
f.choices.sort()
|
||||||
expected = [
|
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)):
|
for exp, got in zip(expected, fix_os_paths(f.choices)):
|
||||||
self.assertEqual(exp[1], got[1])
|
self.assertEqual(exp[1], got[1])
|
||||||
|
@ -999,23 +998,15 @@ class FieldsTests(SimpleTestCase):
|
||||||
f = FilePathField(path=path, allow_folders=True, allow_files=True)
|
f = FilePathField(path=path, allow_folders=True, allow_files=True)
|
||||||
f.choices.sort()
|
f.choices.sort()
|
||||||
expected = [
|
expected = [
|
||||||
('/django/forms/__init__.py', '__init__.py'),
|
('/tests/regressiontests/forms/tests/filepath_test_files/.dot-file', '.dot-file'),
|
||||||
('/django/forms/__init__.pyc', '__init__.pyc'),
|
('/tests/regressiontests/forms/tests/filepath_test_files/directory', 'directory'),
|
||||||
('/django/forms/extras', 'extras'),
|
('/tests/regressiontests/forms/tests/filepath_test_files/fake-image.jpg', 'fake-image.jpg'),
|
||||||
('/django/forms/fields.py', 'fields.py'),
|
('/tests/regressiontests/forms/tests/filepath_test_files/real-text-file.txt', 'real-text-file.txt'),
|
||||||
('/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)):
|
|
||||||
|
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.assertEqual(exp[1], got[1])
|
||||||
self.assertTrue(got[0].endswith(exp[0]))
|
self.assertTrue(got[0].endswith(exp[0]))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue