fix testing.multi_gpu to add pytest marker
@@ -9,6 +9,9 @@ if is_available():
_gpu_limit = int(os.getenv('CUPY_TEST_GPU_LIMIT', '-1'))
+ def gpu(*args, **kwargs):
+ return pytest.mark.gpu(*args, **kwargs)
+
def cudnn(*args, **kwargs):
return pytest.mark.cudnn(*args, **kwargs)
@@ -20,6 +23,7 @@ else:
check_available('pytest attributes')
assert False # Not reachable
+ gpu = _dummy_callable
cudnn = _dummy_callable
slow = _dummy_callable
@@ -36,17 +40,11 @@ def multi_gpu(gpu_num):
check_available('multi_gpu attribute')
# at this point we know pytest is available for sure
+
+ assert 1 < gpu_num
+ def _wrapper(f):
return pytest.mark.skipif(
0 <= _gpu_limit < gpu_num,
- reason='{} GPUs required'.format(gpu_num))
-
-
-def gpu(f):
- """Decorator to indicate that GPU is required to run the test.
-
- Tests can be annotated with this decorator (e.g., ``@gpu``) to
- declare that one GPU is required to run.
- """
-
- check_available('gpu attribute')
- return multi_gpu(1)(pytest.mark.gpu(f))
+ reason='{} GPUs required'.format(gpu_num))(
+ pytest.mark.multi_gpu(f))
+ return _wrapper
