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
50cdac04
Commit
50cdac04
authored
Oct 04, 2010
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test case for copying files from outside the FS
parent
85772b22
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
0 deletions
+14
-0
fs/memoryfs.py
+8
-0
fs/osfs/__init__.py
+0
-0
fs/tests/__init__.py
+6
-0
No files found.
fs/memoryfs.py
View file @
50cdac04
...
...
@@ -513,6 +513,8 @@ class MemoryFS(FS):
@synchronize
def
copydir
(
self
,
src
,
dst
,
overwrite
=
False
,
ignore_errors
=
False
,
chunk_size
=
16384
):
src_dir_entry
=
self
.
_get_dir_entry
(
src
)
if
src_dir_entry
is
None
:
raise
ResourceNotFoundError
(
src
)
src_xattrs
=
src_dir_entry
.
xattrs
.
copy
()
super
(
MemoryFS
,
self
)
.
copydir
(
src
,
dst
,
overwrite
,
ignore_errors
=
ignore_errors
,
chunk_size
=
chunk_size
)
dst_dir_entry
=
self
.
_get_dir_entry
(
dst
)
...
...
@@ -522,6 +524,8 @@ class MemoryFS(FS):
@synchronize
def
movedir
(
self
,
src
,
dst
,
overwrite
=
False
,
ignore_errors
=
False
,
chunk_size
=
16384
):
src_dir_entry
=
self
.
_get_dir_entry
(
src
)
if
src_dir_entry
is
None
:
raise
ResourceNotFoundError
(
src
)
src_xattrs
=
src_dir_entry
.
xattrs
.
copy
()
super
(
MemoryFS
,
self
)
.
movedir
(
src
,
dst
,
overwrite
,
ignore_errors
=
ignore_errors
,
chunk_size
=
chunk_size
)
dst_dir_entry
=
self
.
_get_dir_entry
(
dst
)
...
...
@@ -531,6 +535,8 @@ class MemoryFS(FS):
@synchronize
def
copy
(
self
,
src
,
dst
,
overwrite
=
False
,
chunk_size
=
16384
):
src_dir_entry
=
self
.
_get_dir_entry
(
src
)
if
src_dir_entry
is
None
:
raise
ResourceNotFoundError
(
src
)
src_xattrs
=
src_dir_entry
.
xattrs
.
copy
()
super
(
MemoryFS
,
self
)
.
copy
(
src
,
dst
,
overwrite
,
chunk_size
)
dst_dir_entry
=
self
.
_get_dir_entry
(
dst
)
...
...
@@ -540,6 +546,8 @@ class MemoryFS(FS):
@synchronize
def
move
(
self
,
src
,
dst
,
overwrite
=
False
,
chunk_size
=
16384
):
src_dir_entry
=
self
.
_get_dir_entry
(
src
)
if
src_dir_entry
is
None
:
raise
ResourceNotFoundError
(
src
)
src_xattrs
=
src_dir_entry
.
xattrs
.
copy
()
super
(
MemoryFS
,
self
)
.
move
(
src
,
dst
,
overwrite
,
chunk_size
)
dst_dir_entry
=
self
.
_get_dir_entry
(
dst
)
...
...
fs/osfs/__init__.py
View file @
50cdac04
fs/tests/__init__.py
View file @
50cdac04
...
...
@@ -440,6 +440,11 @@ class FSTestCases(object):
self
.
assert_
(
check
(
"a/foo/bar/baz.txt"
))
def
test_cant_copy_from_os
(
self
):
sys_executable
=
os
.
path
.
abspath
(
os
.
path
.
realpath
(
sys
.
executable
))
print
"COPY"
,
sys_executable
self
.
assertRaises
(
FSError
,
self
.
fs
.
copy
,
sys_executable
,
"py.exe"
)
def
test_copyfile
(
self
):
check
=
self
.
check
contents
=
"If the implementation is hard to explain, it's a bad idea."
...
...
@@ -457,6 +462,7 @@ class FSTestCases(object):
self
.
fs
.
copy
(
"foo/bar/a.txt"
,
"foo/b.txt"
)
self
.
assert_
(
check
(
"foo/bar/a.txt"
))
self
.
assert_
(
check
(
"foo/b.txt"
))
self
.
assert_
(
checkcontents
(
"foo/bar/a.txt"
))
self
.
assert_
(
checkcontents
(
"foo/b.txt"
))
self
.
fs
.
copy
(
"foo/b.txt"
,
"c.txt"
)
...
...
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