mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	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:
		| @@ -985,12 +985,11 @@ class FieldsTests(SimpleTestCase): | ||||
|             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 @@ class FieldsTests(SimpleTestCase): | ||||
|         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])) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user