diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-01-28 07:01:35 -0800 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2019-01-28 11:15:06 -0500 |
commit | 7785e03ba89aafbd949191f126361fb9103cb980 (patch) | |
tree | 5776f7063604285445cfcebf6efb42fd5d063f60 /tests/file_uploads | |
parent | 7444f3252757ed4384623e5afd7dcfeef3e0c74e (diff) | |
download | django-7785e03ba89aafbd949191f126361fb9103cb980.tar.gz |
Fixed #30137 -- Replaced OSError aliases with the canonical OSError.
Used more specific errors (e.g. FileExistsError) as appropriate.
Diffstat (limited to 'tests/file_uploads')
-rw-r--r-- | tests/file_uploads/tests.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/tests/file_uploads/tests.py b/tests/file_uploads/tests.py index fb333dcf13..07a9d9b647 100644 --- a/tests/file_uploads/tests.py +++ b/tests/file_uploads/tests.py @@ -548,16 +548,13 @@ class DirectoryCreationTests(SimpleTestCase): self.obj.testfile.save('foo.txt', SimpleUploadedFile('foo.txt', b'x'), save=False) def test_not_a_directory(self): - """The correct IOError is raised when the upload directory name exists but isn't a directory""" # Create a file with the upload directory name open(UPLOAD_TO, 'wb').close() self.addCleanup(os.remove, UPLOAD_TO) - with self.assertRaises(IOError) as exc_info: + msg = '%s exists and is not a directory.' % UPLOAD_TO + with self.assertRaisesMessage(FileExistsError, msg): with SimpleUploadedFile('foo.txt', b'x') as file: self.obj.testfile.save('foo.txt', file, save=False) - # The test needs to be done on a specific string as IOError - # is raised even without the patch (just not early enough) - self.assertEqual(exc_info.exception.args[0], "%s exists and is not a directory." % UPLOAD_TO) class MultiParserTests(SimpleTestCase): |