Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pyfs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pyfs
Commits
5a0a6a92
Commit
5a0a6a92
authored
Nov 07, 2010
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add testcase for truncating file to a larger size
parent
4ab1e7f3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletions
+14
-1
fs/tests/__init__.py
+14
-1
No files found.
fs/tests/__init__.py
View file @
5a0a6a92
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment