Commit 8a3e9811 authored by Samuel GAIST's avatar Samuel GAIST

[test][helpers] Code cleanup

parent c450aa3b
...@@ -56,7 +56,7 @@ def test(x): ...@@ -56,7 +56,7 @@ def test(x):
def main(): def main():
nworkers = int(sys.argv[1]) nworkers = int(sys.argv[1])
pool = multiprocessing.Pool(processes=nworkers) pool = multiprocessing.Pool(processes=nworkers)
result = pool.map_async(test, range(nworkers)) pool.map_async(test, range(nworkers))
pool.close() pool.close()
pool.join() pool.join()
......
...@@ -88,8 +88,8 @@ class MockDataSink(DataSink): ...@@ -88,8 +88,8 @@ class MockDataSink(DataSink):
class MockDataSource_Crash(DataSource): class MockDataSource_Crash(DataSource):
def next(self): def next(self):
a = b a = b # noqa
def hasMoreData(self): def hasMoreData(self):
a = b a = b # noqa
return False return False
...@@ -46,14 +46,13 @@ import docker ...@@ -46,14 +46,13 @@ import docker
# ---------------------------------------------------------- # ----------------------------------------------------------
# Images used for docker-enabled tests within this and other BEAT packages
DOCKER_TEST_IMAGES = { DOCKER_TEST_IMAGES = {
"docker.idiap.ch/beat/beat.env.system.python": "1.3.0r4", "docker.idiap.ch/beat/beat.env.system.python": "1.3.0r4",
"docker.idiap.ch/beat/beat.env.db.examples": "1.4.0r4", "docker.idiap.ch/beat/beat.env.db.examples": "1.4.0r4",
"docker.idiap.ch/beat/beat.env.cxx": "2.0.0r1", "docker.idiap.ch/beat/beat.env.cxx": "2.0.0r1",
"docker.idiap.ch/beat/beat.env.client": "2.0.0r1", "docker.idiap.ch/beat/beat.env.client": "2.0.0r1",
} }
"""Images used for docker-enabled tests within this and other BEAT packages
"""
def pull_docker_test_images(): def pull_docker_test_images():
...@@ -158,13 +157,22 @@ def skipif(skip_condition, msg=None): ...@@ -158,13 +157,22 @@ def skipif(skip_condition, msg=None):
""" """
class SkipCallable:
"""Helper class to handle both callable and boolean conditions"""
def __init__(self, skip_condition):
self.skip_condition = skip_condition
def __call__(self):
if callable(self.skip_condition):
return skip_condition()
else:
return self.skip_condition
def skip_decorator(f): def skip_decorator(f):
# Allow for both boolean or callable skip conditions. # Allow for both boolean or callable skip conditions.
if callable(skip_condition): skip_val = SkipCallable(skip_condition)
skip_val = lambda: skip_condition()
else:
skip_val = lambda: skip_condition
# We need to define *two* skippers because Python doesn't allow both # We need to define *two* skippers because Python doesn't allow both
# return with value and yield inside the same function. # return with value and yield inside the same function.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment