diff options
author | Tim Graham <timograham@gmail.com> | 2017-01-25 10:13:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-25 10:13:08 -0500 |
commit | 632c4ffd9cb1da273303bcd8005fff216506c795 (patch) | |
tree | 4e475379e7e210a513789513021720b8b4808f7c /tests/file_storage | |
parent | 3f0c4fe18fe9850bb2f56be138012add4b54873d (diff) | |
download | django-632c4ffd9cb1da273303bcd8005fff216506c795.tar.gz |
Refs #23919 -- Replaced errno checking with PEP 3151 exceptions.
Diffstat (limited to 'tests/file_storage')
-rw-r--r-- | tests/file_storage/tests.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py index d33ca67c33..ba77622067 100644 --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -1,4 +1,3 @@ -import errno import os import shutil import sys @@ -416,9 +415,9 @@ class FileStorageTests(SimpleTestCase): real_makedirs(path) elif path == os.path.join(self.temp_dir, 'raced'): real_makedirs(path) - raise OSError(errno.EEXIST, 'simulated EEXIST') + raise FileNotFoundError() elif path == os.path.join(self.temp_dir, 'error'): - raise OSError(errno.EACCES, 'simulated EACCES') + raise FileExistsError() else: self.fail('unexpected argument %r' % path) @@ -433,8 +432,8 @@ class FileStorageTests(SimpleTestCase): with self.storage.open('raced/test.file') as f: self.assertEqual(f.read(), b'saved with race') - # OSErrors aside from EEXIST are still raised. - with self.assertRaises(OSError): + # Exceptions aside from FileNotFoundError are raised. + with self.assertRaises(FileExistsError): self.storage.save('error/test.file', ContentFile('not saved')) finally: os.makedirs = real_makedirs @@ -452,9 +451,9 @@ class FileStorageTests(SimpleTestCase): real_remove(path) elif path == os.path.join(self.temp_dir, 'raced.file'): real_remove(path) - raise OSError(errno.ENOENT, 'simulated ENOENT') + raise FileNotFoundError() elif path == os.path.join(self.temp_dir, 'error.file'): - raise OSError(errno.EACCES, 'simulated EACCES') + raise PermissionError() else: self.fail('unexpected argument %r' % path) @@ -469,9 +468,9 @@ class FileStorageTests(SimpleTestCase): self.storage.delete('raced.file') self.assertFalse(self.storage.exists('normal.file')) - # OSErrors aside from ENOENT are still raised. + # Exceptions aside from FileNotFoundError are raised. self.storage.save('error.file', ContentFile('delete with error')) - with self.assertRaises(OSError): + with self.assertRaises(PermissionError): self.storage.delete('error.file') finally: os.remove = real_remove |