mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-01-03 05:00:15 +00:00
Make ut_test compatible with Python 3 (#1838)
This may allow removing Python 2 on newer distros. Co-authored-by: Takeshi Nakatani <ggtakec@gmail.com>
This commit is contained in:
parent
a44ea7c12a
commit
fc7543fa25
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# s3fs - FUSE-based file system backed by Amazon S3
|
# s3fs - FUSE-based file system backed by Amazon S3
|
||||||
#
|
#
|
||||||
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
import ConfigParser
|
|
||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
@ -42,7 +41,7 @@ class OssfsUnitTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_read_file(self):
|
def test_read_file(self):
|
||||||
filename = "%s" % (self.random_string(10))
|
filename = "%s" % (self.random_string(10))
|
||||||
print filename
|
print(filename)
|
||||||
|
|
||||||
f = open(filename, 'w')
|
f = open(filename, 'w')
|
||||||
data = self.random_string(1000)
|
data = self.random_string(1000)
|
||||||
@ -61,7 +60,7 @@ class OssfsUnitTest(unittest.TestCase):
|
|||||||
def test_rename_file(self):
|
def test_rename_file(self):
|
||||||
filename1 = "%s" % (self.random_string(10))
|
filename1 = "%s" % (self.random_string(10))
|
||||||
filename2 = "%s" % (self.random_string(10))
|
filename2 = "%s" % (self.random_string(10))
|
||||||
print filename1, filename2
|
print(filename1, filename2)
|
||||||
|
|
||||||
f = open(filename1, 'w+')
|
f = open(filename1, 'w+')
|
||||||
data1 = self.random_string(1000)
|
data1 = self.random_string(1000)
|
||||||
@ -81,7 +80,7 @@ class OssfsUnitTest(unittest.TestCase):
|
|||||||
def test_rename_file2(self):
|
def test_rename_file2(self):
|
||||||
filename1 = "%s" % (self.random_string(10))
|
filename1 = "%s" % (self.random_string(10))
|
||||||
filename2 = "%s" % (self.random_string(10))
|
filename2 = "%s" % (self.random_string(10))
|
||||||
print filename1, filename2
|
print(filename1, filename2)
|
||||||
|
|
||||||
f = open(filename1, 'w')
|
f = open(filename1, 'w')
|
||||||
data1 = self.random_string(1000)
|
data1 = self.random_string(1000)
|
||||||
@ -104,7 +103,7 @@ class OssfsUnitTest(unittest.TestCase):
|
|||||||
filename = "%s" % (self.random_string(10))
|
filename = "%s" % (self.random_string(10))
|
||||||
fd = os.open(filename, os.O_CREAT|os.O_RDWR)
|
fd = os.open(filename, os.O_CREAT|os.O_RDWR)
|
||||||
try:
|
try:
|
||||||
os.write(fd, 'a' * 42)
|
os.write(fd, b'a' * 42)
|
||||||
self.assertEqual(os.fstat(fd).st_size, 42)
|
self.assertEqual(os.fstat(fd).st_size, 42)
|
||||||
os.ftruncate(fd, 100)
|
os.ftruncate(fd, 100)
|
||||||
self.assertEqual(os.fstat(fd).st_size, 100)
|
self.assertEqual(os.fstat(fd).st_size, 100)
|
||||||
|
Loading…
Reference in New Issue
Block a user