在Python中使用绿色测试运行程序跳过测试

在Python中使用绿色测试运行程序跳过测试,python,pytest,python-green,Python,Pytest,Python Green,目前,我正在使用py.test运行测试,并将跳过的测试定义为: @pytest.mark.skipif(True, reason="blockchain.info support currently disabled") class BlockChainBTCTestCase(CoinTestCase, unittest.TestCase): ... @pytest.mark.skipif(is_slow_test_hostile(), reason="Running send

目前,我正在使用py.test运行测试,并将跳过的测试定义为:

@pytest.mark.skipif(True, reason="blockchain.info support currently disabled")
class BlockChainBTCTestCase(CoinTestCase, unittest.TestCase):   
    ...

@pytest.mark.skipif(is_slow_test_hostile(), reason="Running send + receive loop may take > 20 minutes")
def test_send_receive_external(self):
    """ Test sending and receiving external transaction within the backend wallet.

如果我想将测试迁移到绿色,绿色是否提供相应的设施?

是!绿色支持
unittest
内置的
unittest.skipIf(条件、原因)
函数,以及类似的
skip()
skipUnless()
SkipTest
功能

@unittest.skipIf(True, reason="Just skip all the tests in the test case.")
class MyTestCase(unittest.TestCase):   
    ...

class MyOtherTestCase(unittest.TestCase):
    @unittest.skipIf(stuff_is_slow(), reason="Stuff is slow right now.")
    def test_fast_stuff(self):
        "This is a great test if stuff is fast at the moment."
        ...
请注意,这需要Python2.7或更高版本