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
This commit is contained in:
parent
3f9994681a
commit
e10d5aa330
@ -31,6 +31,21 @@ import pyeclib_c
|
|||||||
from pyeclib.ec_iface import PyECLib_EC_Types
|
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:
|
class Timer:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -50,9 +65,9 @@ class Timer:
|
|||||||
self.end_time = time.time()
|
self.end_time = time.time()
|
||||||
return self.curr_delta()
|
return self.curr_delta()
|
||||||
|
|
||||||
|
|
||||||
class TestPyECLib(unittest.TestCase):
|
class TestPyECLib(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
self.num_datas = [12, 12, 12]
|
self.num_datas = [12, 12, 12]
|
||||||
self.num_parities = [2, 3, 4]
|
self.num_parities = [2, 3, 4]
|
||||||
|
Loading…
Reference in New Issue
Block a user