Commit 324d48d0 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Switched to Python 3-compatible octal notation.

parent 85cd4589
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ import sys

if os.name == 'posix':
    def become_daemon(our_home_dir='.', out_log='/dev/null',
                      err_log='/dev/null', umask=022):
                      err_log='/dev/null', umask=0o022):
        "Robustly turn into a UNIX daemon, running in our_home_dir."
        # First fork
        try:
+3 −3
Original line number Diff line number Diff line
@@ -143,14 +143,14 @@ class HttpDateProcessing(unittest.TestCase):
    def testParsingRfc1123(self):
        parsed = parse_http_date('Sun, 06 Nov 1994 08:49:37 GMT')
        self.assertEqual(datetime.utcfromtimestamp(parsed),
                         datetime(1994, 11, 06, 8, 49, 37))
                         datetime(1994, 11, 6, 8, 49, 37))

    def testParsingRfc850(self):
        parsed = parse_http_date('Sunday, 06-Nov-94 08:49:37 GMT')
        self.assertEqual(datetime.utcfromtimestamp(parsed),
                         datetime(1994, 11, 06, 8, 49, 37))
                         datetime(1994, 11, 6, 8, 49, 37))

    def testParsingAsctime(self):
        parsed = parse_http_date('Sun Nov  6 08:49:37 1994')
        self.assertEqual(datetime.utcfromtimestamp(parsed),
                         datetime(1994, 11, 06, 8, 49, 37))
                         datetime(1994, 11, 6, 8, 49, 37))
+3 −3
Original line number Diff line number Diff line
@@ -424,7 +424,7 @@ class FileSaveRaceConditionTest(unittest.TestCase):
class FileStoragePermissions(unittest.TestCase):
    def setUp(self):
        self.old_perms = settings.FILE_UPLOAD_PERMISSIONS
        settings.FILE_UPLOAD_PERMISSIONS = 0666
        settings.FILE_UPLOAD_PERMISSIONS = 0o666
        self.storage_dir = tempfile.mkdtemp()
        self.storage = FileSystemStorage(self.storage_dir)

@@ -434,8 +434,8 @@ class FileStoragePermissions(unittest.TestCase):

    def test_file_upload_permissions(self):
        name = self.storage.save("the_file", ContentFile(b"data"))
        actual_mode = os.stat(self.storage.path(name))[0] & 0777
        self.assertEqual(actual_mode, 0666)
        actual_mode = os.stat(self.storage.path(name))[0] & 0o777
        self.assertEqual(actual_mode, 0o666)


class FileStoragePathParsing(unittest.TestCase):
+3 −3
Original line number Diff line number Diff line
@@ -362,16 +362,16 @@ class DirectoryCreationTests(unittest.TestCase):
        if not os.path.isdir(temp_storage.location):
            os.makedirs(temp_storage.location)
        if os.path.isdir(UPLOAD_TO):
            os.chmod(UPLOAD_TO, 0700)
            os.chmod(UPLOAD_TO, 0o700)
            shutil.rmtree(UPLOAD_TO)

    def tearDown(self):
        os.chmod(temp_storage.location, 0700)
        os.chmod(temp_storage.location, 0o700)
        shutil.rmtree(temp_storage.location)

    def test_readonly_root(self):
        """Permission errors are not swallowed"""
        os.chmod(temp_storage.location, 0500)
        os.chmod(temp_storage.location, 0o500)
        try:
            self.obj.testfile.save('foo.txt', SimpleUploadedFile('foo.txt', b'x'))
        except OSError as err: