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
539f4be6
Commit
539f4be6
authored
Aug 19, 2008
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More work on the test suite
parent
7973da6a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletions
+29
-1
fs/fs.py
+12
-0
fs/osfs.py
+1
-1
fs/tests.py
+16
-0
No files found.
fs/fs.py
View file @
539f4be6
...
@@ -400,6 +400,18 @@ class FS(object):
...
@@ -400,6 +400,18 @@ class FS(object):
def
getsize
(
self
,
path
):
def
getsize
(
self
,
path
):
return
self
.
getinfo
(
path
)[
'size'
]
return
self
.
getinfo
(
path
)[
'size'
]
def
makefile
(
self
,
path
,
data
):
f
=
None
try
:
f
=
self
.
open
(
path
,
"wb"
)
f
.
write
(
data
)
finally
:
if
f
is
not
None
:
f
.
close
()
return
True
class
SubFS
(
FS
):
class
SubFS
(
FS
):
...
...
fs/osfs.py
View file @
539f4be6
...
@@ -142,7 +142,7 @@ if __name__ == "__main__":
...
@@ -142,7 +142,7 @@ if __name__ == "__main__":
osfs
=
OSFS
(
"~/projects"
)
osfs
=
OSFS
(
"~/projects"
)
print
osfs
print
osfs
for
filename
in
osfs
.
walk
_
files
(
"/"
,
"*.pov"
):
for
filename
in
osfs
.
walkfiles
(
"/"
,
"*.pov"
):
print
filename
print
filename
print
osfs
.
getinfo
(
filename
)
print
osfs
.
getinfo
(
filename
)
...
...
fs/tests.py
View file @
539f4be6
...
@@ -137,6 +137,7 @@ class TestFS(unittest.TestCase):
...
@@ -137,6 +137,7 @@ class TestFS(unittest.TestCase):
def
test_removedir
(
self
):
def
test_removedir
(
self
):
check
=
self
.
check
check
=
self
.
check
self
.
fs
.
makedir
(
"a"
)
self
.
fs
.
makedir
(
"a"
)
self
.
assert_
(
check
(
"a"
))
self
.
assert_
(
check
(
"a"
))
...
@@ -157,6 +158,21 @@ class TestFS(unittest.TestCase):
...
@@ -157,6 +158,21 @@ class TestFS(unittest.TestCase):
self
.
assert_
(
not
check
(
"foo/bar"
))
self
.
assert_
(
not
check
(
"foo/bar"
))
self
.
assert_
(
not
check
(
"foo"
))
self
.
assert_
(
not
check
(
"foo"
))
def
test_rename
(
self
):
check
=
self
.
check
self
.
fs
.
open
(
"foo.txt"
,
'wt'
)
.
write
(
"Hello, World!"
)
self
.
assert_
(
check
(
"foo.txt"
))
self
.
fs
.
rename
(
"foo.txt"
,
"bar.txt"
)
self
.
assert_
(
check
(
"bar.txt"
))
def
test_makefile
(
self
):
check
=
self
.
check
self
.
fs
.
makefile
(
"foo.txt"
,
"Hello, World!"
)
data
=
self
.
fs
.
open
(
"foo.txt"
)
.
read
()
self
.
assertEqual
(
data
,
"Hello, World!"
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
#t = TestFS()
#t = TestFS()
...
...
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