From ba374d0e6a34220be7c412dfebe7b1f9b15d9833 Mon Sep 17 00:00:00 2001 From: Manuel Gunther <siebenkopf@googlemail.com> Date: Wed, 2 Sep 2015 15:49:50 -0600 Subject: [PATCH] Added test decorator to test for the availability of a database --- bob/bio/base/test/utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bob/bio/base/test/utils.py b/bob/bio/base/test/utils.py index 353078cf..a3e77135 100644 --- a/bob/bio/base/test/utils.py +++ b/bob/bio/base/test/utils.py @@ -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 -- GitLab