Commit 5a0a6a92 by rfkelly0

add testcase for truncating file to a larger size

parent 4ab1e7f3
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
""" """
from __future__ import with_statement
# Send any output from the logging module to stdout, so it will # Send any output from the logging module to stdout, so it will
# be captured by nose and reported appropriately # be captured by nose and reported appropriately
import sys import sys
...@@ -14,6 +16,7 @@ logging.basicConfig(level=logging.ERROR, stream=sys.stdout) ...@@ -14,6 +16,7 @@ logging.basicConfig(level=logging.ERROR, stream=sys.stdout)
from fs.base import * from fs.base import *
from fs.path import * from fs.path import *
from fs.errors import * from fs.errors import *
from fs.filelike import StringIO
import datetime import datetime
import unittest import unittest
...@@ -21,7 +24,6 @@ import os, os.path ...@@ -21,7 +24,6 @@ import os, os.path
import pickle import pickle
import random import random
import copy import copy
from StringIO import StringIO
import time import time
try: try:
...@@ -617,6 +619,17 @@ class FSTestCases(object): ...@@ -617,6 +619,17 @@ class FSTestCases(object):
f.truncate() f.truncate()
checkcontents("hello","12345") checkcontents("hello","12345")
def test_truncate_to_larger_size(self):
with self.fs.open("hello","w") as f:
f.truncate(30)
self.assertEquals(self.fs.getsize("hello"),30)
with self.fs.open("hello","r+") as f:
f.seek(25)
f.write("123456")
with self.fs.open("hello","r") as f:
f.seek(25)
self.assertEquals(f.read(),"123456")
def test_with_statement(self): def test_with_statement(self):
# This is a little tricky since 'with' is actually new syntax. # This is a little tricky since 'with' is actually new syntax.
# We use eval() to make this method safe for old python versions. # We use eval() to make this method safe for old python versions.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment