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
1dfc4c0a
Commit
1dfc4c0a
authored
Sep 18, 2009
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make error classes pickleable, and add appropriate tests
parent
36a6fafa
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
3 deletions
+32
-3
fs/errors.py
+6
-3
fs/tests/test_errors.py
+26
-0
No files found.
fs/errors.py
View file @
1dfc4c0a
...
...
@@ -37,12 +37,15 @@ class FSError(Exception):
def
__unicode__
(
self
):
return
unicode
(
str
(
self
))
def
__getstate__
(
self
):
return
self
.
__dict__
.
copy
()
class
PathError
(
FSError
):
"""Exception for errors to do with a path string."""
default_message
=
"Path is invalid:
%(path)
s"
def
__init__
(
self
,
path
,
**
kwds
):
def
__init__
(
self
,
path
=
""
,
**
kwds
):
self
.
path
=
path
super
(
PathError
,
self
)
.
__init__
(
**
kwds
)
...
...
@@ -51,7 +54,7 @@ class OperationFailedError(FSError):
"""Base exception class for errors associated with a specific operation."""
default_message
=
"Unable to
%(opname)
s: unspecified error [
%(errno)
s -
%(details)
s]"
def
__init__
(
self
,
opname
,
path
=
None
,
**
kwds
):
def
__init__
(
self
,
opname
=
""
,
path
=
None
,
**
kwds
):
self
.
opname
=
opname
self
.
path
=
path
self
.
errno
=
getattr
(
kwds
.
get
(
"details"
,
None
),
"errno"
,
None
)
...
...
@@ -82,7 +85,7 @@ class ResourceError(FSError):
"""Base exception class for error associated with a specific resource."""
default_message
=
"Unspecified resource error:
%(path)
s"
def
__init__
(
self
,
path
,
**
kwds
):
def
__init__
(
self
,
path
=
""
,
**
kwds
):
self
.
path
=
path
self
.
opname
=
kwds
.
pop
(
"opname"
,
None
)
super
(
ResourceError
,
self
)
.
__init__
(
**
kwds
)
...
...
fs/tests/test_errors.py
0 → 100644
View file @
1dfc4c0a
"""
fs.tests.test_errors: testcases for the fs error classes functions
"""
import
unittest
import
fs.tests
from
fs.errors
import
*
import
pickle
from
fs.path
import
*
class
TestErrorPickling
(
unittest
.
TestCase
):
def
test_pickling
(
self
):
def
assert_dump_load
(
e
):
e2
=
pickle
.
loads
(
pickle
.
dumps
(
e
))
self
.
assertEqual
(
e
.
__dict__
,
e2
.
__dict__
)
assert_dump_load
(
FSError
())
assert_dump_load
(
PathError
(
"/some/path"
))
assert_dump_load
(
ResourceNotFoundError
(
"/some/other/path"
))
assert_dump_load
(
UnsupportedError
(
"makepony"
))
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