try:
    import pytest
    _error = None
except ImportError as e:
    _error = e


def is_available():
    return _error is None


def check_available():
    if _error is not None:
        raise RuntimeError('''\
{} is not available.

Reason: {}: {}'''.format(__name__, type(_error).__name__, _error))


def get_error():
    return _error


if _error is None:
    gpu = pytest.mark.gpu
    cudnn = pytest.mark.cudnn
    slow = pytest.mark.slow

else:
    def _dummy_callable(*args, **kwargs):
        check_available()
        assert False  # Not reachable

    gpu = _dummy_callable
    cudnn = _dummy_callable
    slow = _dummy_callable


def multi_gpu(gpu_num):
    check_available()
    return pytest.mark.multi_gpu(gpu=gpu_num)

@@ -1,8 +1,36 @@
+import os%0Aimport unittest%0A%0A%0A
 try:%0A   
@@ -389,29 +389,71 @@
     
+_
 gpu
- = pytest.mark.gpu
+_limit = int(os.getenv('CHAINER_TESTING_GPU_LIMIT', '-1'))%0A
 %0A   
@@ -625,34 +625,8 @@
 le%0A%0A
-    gpu = _dummy_callable%0A
     
@@ -702,16 +702,413 @@
 u_num):%0A
+    %22%22%22Decorator to indicate number of GPUs required to run the test.%0A%0A    Tests can be annotated with this decorator (e.g., %60%60@multi_gpu(2)%60%60) to%0A    declare number of GPUs required to run. When running tests, if%0A    %60%60CHAINER_TESTING_GPU_LIMIT%60%60 environment variable is set to value greater%0A    than or equals to 0, test cases that require GPUs more than the limit will%0A    be skipped.%0A    %22%22%22%0A%0A
     chec
@@ -1136,39 +1136,391 @@
 urn 
-py
+unit
 test.
-mark.multi_gpu(gpu=gpu_num
+skipIf(%0A        0 %3C= _gpu_limit and _gpu_limit %3C gpu_num,%0A        reason='%7B%7D GPUs required'.format(gpu_num))%0A%0A%0Adef gpu(f):%0A    %22%22%22Decorator to indicate that GPU is required to run the test.%0A%0A    Tests can be annotated with this decorator (e.g., %60%60@gpu%60%60) to%0A    declare that one GPU is required to run.%0A    %22%22%22%0A%0A    check_available()%0A    return multi_gpu(1)(pytest.mark.gpu(f)
 )%0A

rewrite gpu/multi_gpu decorator with unittest.skipIf