Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test_read_write

  • Loading branch information...
commit a98f07247094047db3c408b2f85837e97db18aab 1 parent 0d5123d
@mikejs authored
Showing with 25 additions and 5 deletions.
  1. +25 −5 tests/basic.py
View
30 tests/basic.py
@@ -34,16 +34,36 @@ def test_read_write(self):
r.read())
def test_stat(self):
+ def assert_stat(path, mode=0555, size=4):
+ stat_result = os.stat(path)
+ st_mode = stat_result.st_mode
+ self.assert_(stat.S_ISREG(st_mode))
+ self.assertEquals(mode, stat.S_IMODE(st_mode))
+ self.assertEquals(size, stat_result.st_size)
+
path = os.path.join(self.mount, 'testfile.txt')
with open(path, 'w') as w:
+ assert_stat(path, size=0)
w.write('test')
+ w.flush()
+ assert_stat(path)
+
+ assert_stat(path)
+
+ def test_read_write(self):
+ path = os.path.join(self.mount, 'file')
+
+ with open(path, 'w') as w:
+ self.assertRaises(IOError, open, path, 'w')
- stat_result = os.stat(path)
- mode = stat_result.st_mode
+ w.write('Hello')
+ w.flush()
- self.assert_(stat.S_ISREG(mode))
- self.assertEquals(0555, stat.S_IMODE(mode))
- self.assertEquals(4, stat_result.st_size)
+ with open(path, 'r') as r:
+ self.assertEquals('Hello', r.read())
+ w.write(' world')
+ w.flush()
+ self.assertEquals(' world', r.read())
def test_ls(self):
self.assertEquals(0, len(os.listdir(self.mount)))
Please sign in to comment.
Something went wrong with that request. Please try again.