summaryrefslogtreecommitdiff
path: root/fs/tests/__init__.py
diff options
context:
space:
mode:
authorwillmcgugan@gmail.com <willmcgugan@gmail.com@67cdc799-7952-0410-af00-57a81ceafa0f>2013-09-09 21:47:01 +0000
committerwillmcgugan@gmail.com <willmcgugan@gmail.com@67cdc799-7952-0410-af00-57a81ceafa0f>2013-09-09 21:47:01 +0000
commitfbe1238c34ef238a0a50166d6b2ec19a7ee94435 (patch)
tree66ab10bfef79e58d6b5a17a74e9291d3fbb23127 /fs/tests/__init__.py
parentb51d5d2b3641204335d4247fe4f1321c52aafecc (diff)
downloadpyfilesystem-fbe1238c34ef238a0a50166d6b2ec19a7ee94435.tar.gz
Changed signature for 'createfile' everywhere, fixes #133
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@875 67cdc799-7952-0410-af00-57a81ceafa0f
Diffstat (limited to 'fs/tests/__init__.py')
-rw-r--r--fs/tests/__init__.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/tests/__init__.py b/fs/tests/__init__.py
index 9fd3cda..42f396f 100644
--- a/fs/tests/__init__.py
+++ b/fs/tests/__init__.py
@@ -136,6 +136,18 @@ class FSTestCases(object):
self.assertEquals(f.read(), b("test file overwrite"))
f.close()
+ def test_createfile(self):
+ """Test createfile"""
+ test = b('now with content')
+ self.fs.createfile("test.txt")
+ self.assert_(self.fs.exists("test.txt"))
+ self.assertEqual(self.fs.getcontents("test.txt", "rb"), b(''))
+ self.fs.setcontents("test.txt", test)
+ self.fs.createfile("test.txt")
+ self.assertEqual(self.fs.getcontents("test.txt", "rb"), test)
+ self.fs.createfile("test.txt", wipe=True)
+ self.assertEqual(self.fs.getcontents("test.txt", "rb"), b(''))
+
def test_setcontents(self):
# setcontents() should accept both a string...
self.fs.setcontents("hello", b("world"))
@@ -152,7 +164,7 @@ class FSTestCases(object):
b("to you, good sir!")), chunk_size=2)
self.assertEquals(self.fs.getcontents(
"hello", "rb"), b("to you, good sir!"))
- self.fs.setcontents("hello", "", "wb")
+ self.fs.setcontents("hello", b"")
self.assertEquals(self.fs.getcontents("hello", "rb"), "")
def test_setcontents_async(self):
@@ -888,7 +900,7 @@ class FSTestCases(object):
def test_zero_read(self):
"""Test read(0) returns empty string"""
- self.fs.setcontents('foo.txt', b('Hello, World'), 'wb')
+ self.fs.setcontents('foo.txt', b('Hello, World') )
with self.fs.open('foo.txt', 'rb') as f:
self.assert_(len(f.read(0)) == 0)
with self.fs.open('foo.txt', 'rt') as f: