diff options
author | Kota Tsuyuzaki <bloodeagle40234@gmail.com> | 2015-03-04 17:48:05 +0900 |
---|---|---|
committer | Kota Tsuyuzaki <bloodeagle40234@gmail.com> | 2015-03-04 19:54:37 +0900 |
commit | e10d5aa330898bce4f1ac8d29059e374a12954c4 (patch) | |
tree | d789e48ce808c882cee395fac7a6639d65652188 | |
parent | 3f9994681a032dbc1688822ce53e80fd2dc50acf (diff) | |
download | pyeclib-e10d5aa330898bce4f1ac8d29059e374a12954c4.tar.gz |
Enable UnitTest to choose tests to do
This patch introduces a global variable "_available_backends"
meaning which backends are available in the test running environment.
PyECLib supports several backends and some of them needs extra
installation in outside of PyECLib setuptools. When such backends
doesn't be installed yet, some unit tests might fail.
To clarify which test should be done in the user environment and
to skip unnecessary tests if the backends are not available, we could
use the new variable with skipif decorator of unittest library.
E.g.:
from unittest import skipIf
@skipIf(PyECLib_EC_Types.shss not in _available_backends,
"shss backend is not available in your enviromnet")
def test_shss(self):
pass
-rw-r--r-- | test/test_pyeclib_c.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/test_pyeclib_c.py b/test/test_pyeclib_c.py index ee54df7..a580ee7 100644 --- a/test/test_pyeclib_c.py +++ b/test/test_pyeclib_c.py @@ -31,6 +31,21 @@ import pyeclib_c from pyeclib.ec_iface import PyECLib_EC_Types +def collect_available_backends(): + available_backends = [] + for ec_type in PyECLib_EC_Types: + try: + if ec_type == PyECLib_EC_Types.flat_xor_hd: + handle = pyeclib_c.init(10, 5, ec_type.value, 3) + else: + handle = pyeclib_c.init(10, 4, ec_type.value) + available_backends.append(ec_type) + except: + pass + return available_backends + +_available_backends = collect_available_backends() + class Timer: def __init__(self): @@ -50,9 +65,9 @@ class Timer: self.end_time = time.time() return self.curr_delta() - class TestPyECLib(unittest.TestCase): + def __init__(self, *args): self.num_datas = [12, 12, 12] self.num_parities = [2, 3, 4] |