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
076bef55
Commit
076bef55
authored
Jun 16, 2009
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable explicit locking in ThreadingTestCase tests
parent
924df19c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
fs/tests/__init__.py
+15
-2
No files found.
fs/tests/__init__.py
View file @
076bef55
...
@@ -43,6 +43,8 @@ class FSTestCases:
...
@@ -43,6 +43,8 @@ class FSTestCases:
def
test_root_dir
(
self
):
def
test_root_dir
(
self
):
self
.
assertTrue
(
self
.
fs
.
isdir
(
""
))
self
.
assertTrue
(
self
.
fs
.
isdir
(
""
))
self
.
assertTrue
(
self
.
fs
.
isdir
(
"/"
))
self
.
assertTrue
(
self
.
fs
.
isdir
(
"/"
))
self
.
assertTrue
(
self
.
fs
.
getinfo
(
""
))
self
.
assertTrue
(
self
.
fs
.
getinfo
(
"/"
))
def
test_debug
(
self
):
def
test_debug
(
self
):
str
(
self
.
fs
)
str
(
self
.
fs
)
...
@@ -327,7 +329,7 @@ class FSTestCases:
...
@@ -327,7 +329,7 @@ class FSTestCases:
makefile
(
"a/3.txt"
)
makefile
(
"a/3.txt"
)
self
.
fs
.
makedir
(
"a/foo/bar"
,
recursive
=
True
)
self
.
fs
.
makedir
(
"a/foo/bar"
,
recursive
=
True
)
makefile
(
"a/foo/bar/baz.txt"
)
makefile
(
"a/foo/bar/baz.txt"
)
self
.
fs
.
copydir
(
"a"
,
"copy of a"
)
self
.
fs
.
copydir
(
"a"
,
"copy of a"
)
self
.
assert_
(
check
(
"copy of a/1.txt"
))
self
.
assert_
(
check
(
"copy of a/1.txt"
))
self
.
assert_
(
check
(
"copy of a/2.txt"
))
self
.
assert_
(
check
(
"copy of a/2.txt"
))
...
@@ -458,9 +460,17 @@ class FSTestCases:
...
@@ -458,9 +460,17 @@ class FSTestCases:
class
ThreadingTestCases
:
class
ThreadingTestCases
:
"""Testcases for thread-safety of FS implementations."""
"""Testcases for thread-safety of FS implementations."""
_ThreadingTestCasesLock
=
threading
.
RLock
()
def
_yield
(
self
):
def
_yield
(
self
):
time
.
sleep
(
0.01
)
time
.
sleep
(
0.01
)
def
_lock
(
self
):
self
.
_ThreadingTestCasesLock
.
acquire
()
def
_unlock
(
self
):
self
.
_ThreadingTestCasesLock
.
release
()
def
_makeThread
(
self
,
func
,
errors
):
def
_makeThread
(
self
,
func
,
errors
):
def
runThread
():
def
runThread
():
try
:
try
:
...
@@ -532,6 +542,7 @@ class ThreadingTestCases:
...
@@ -532,6 +542,7 @@ class ThreadingTestCases:
class
RunFSTestCases
(
unittest
.
TestCase
,
FSTestCases
):
class
RunFSTestCases
(
unittest
.
TestCase
,
FSTestCases
):
"""Run all FSTestCases against a subdir of self.fs"""
"""Run all FSTestCases against a subdir of self.fs"""
def
__init__
(
this
,
subdir
):
def
__init__
(
this
,
subdir
):
this
.
subdir
=
subdir
for
meth
in
dir
(
this
):
for
meth
in
dir
(
this
):
if
not
meth
.
startswith
(
"test_"
):
if
not
meth
.
startswith
(
"test_"
):
continue
continue
...
@@ -543,6 +554,8 @@ class ThreadingTestCases:
...
@@ -543,6 +554,8 @@ class ThreadingTestCases:
this
.
fs
=
self
.
fs
.
opendir
(
subdir
)
this
.
fs
=
self
.
fs
.
opendir
(
subdir
)
self
.
_yield
()
self
.
_yield
()
getattr
(
this
,
meth
)()
getattr
(
this
,
meth
)()
def
check
(
this
,
p
):
return
self
.
check
(
pathjoin
(
this
.
subdir
,
relpath
(
p
)))
def
thread1
():
def
thread1
():
RunFSTestCases
(
"thread1"
)
RunFSTestCases
(
"thread1"
)
def
thread2
():
def
thread2
():
...
@@ -588,7 +601,7 @@ class ThreadingTestCases:
...
@@ -588,7 +601,7 @@ class ThreadingTestCases:
self
.
_runThreads
(
makedir
,
removedir
)
self
.
_runThreads
(
makedir
,
removedir
)
if
self
.
fs
.
isdir
(
"testdir"
):
if
self
.
fs
.
isdir
(
"testdir"
):
self
.
assertEquals
(
len
(
errors
),
1
)
self
.
assertEquals
(
len
(
errors
),
1
)
self
.
assertTrue
(
isinstance
(
errors
[
0
]
),
ResourceNotFoundError
)
self
.
assertTrue
(
isinstance
(
errors
[
0
]
,
ResourceNotFoundError
)
)
self
.
fs
.
removedir
(
"testdir"
)
self
.
fs
.
removedir
(
"testdir"
)
else
:
else
:
self
.
assertEquals
(
len
(
errors
),
0
)
self
.
assertEquals
(
len
(
errors
),
0
)
...
...
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