Disabling Python nosetests

前端 未结 5 1273
南方客
南方客 2020-12-08 18:42

When using nosetests for Python it is possible to disable a unit test by setting the test function\'s __test__ attribute to false. I have implemented this usin

5条回答
  •  余生分开走
    2020-12-08 18:57

    I think you will also need to rename your decorator to something that has not got test in. The below only fails on the second test for me and the first does not show up in the test suite.

    def unit_disabled(func):
        def wrapper(func):
             func.__test__ = False
             return func
    
        return wrapper
    
    @unit_disabled
    def test_my_sample_test():
        assert 1 <> 1
    
    def test2_my_sample_test():
        assert 1 <> 1
    

提交回复
热议问题