Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.bio.base
Commits
ba374d0e
Commit
ba374d0e
authored
Sep 02, 2015
by
Manuel Günther
Browse files
Added test decorator to test for the availability of a database
parent
a36588f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
bob/bio/base/test/utils.py
View file @
ba374d0e
...
...
@@ -58,6 +58,20 @@ def grid_available(test):
raise
SkipTest
(
"Skipping test since gridtk is not available: %s"
%
e
)
return
wrapper
def
db_available
(
dbname
):
'''Decorator that checks if a given bob.db database is available.
This is a double-indirect decorator, see http://thecodeship.com/patterns/guide-to-python-function-decorators'''
def
wrapped_function
(
test
):
@
functools
.
wraps
(
test
)
def
wrapper
(
*
args
,
**
kwargs
):
try
:
__import__
(
'bob.db.%s'
%
dbname
)
return
test
(
*
args
,
**
kwargs
)
except
ImportError
as
e
:
raise
SkipTest
(
"Skipping test since the database bob.db.%s seems not to be available: %s"
%
(
dbname
,
e
))
return
wrapper
return
wrapped_function
atnt_default_directory
=
os
.
environ
[
'ATNT_DATABASE_DIRECTORY'
]
if
'ATNT_DATABASE_DIRECTORY'
in
os
.
environ
else
"/idiap/group/biometric/databases/orl/"
global
atnt_downloaded_directory
...
...
Write
Preview
Supports
Markdown
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