Search code examples
pythontestingnosenose-parameterized

skip only one parameter from the parameterized list in python nose-parameterized


As I understand, parameterized.expand([1, 2, 3]) will create three test cases. I would like to know how can I skip only one of them?

I know that @unitest.skip() will skip the whole 3 test cases, I only wanna to skip one of them.

Here is a simple code

from nose_parameterized import parameterized
import unittest

class Read(unittest.TestCase):
    @parameterized.expand(['1', '2', '3', '4'])
    def test000_test1(self, operation):
        print operation
        self.assertGreater(5, int(operation))

Solution

  • I did this trick while some one may be find another pro method.

    from nose_parameterized import parameterized
    import unittest
    
    
    class Read(unittest.TestCase):
        @parameterized.expand(['1', '2', '3', '4'])
        def test000_test1(self, operation):
            if operation == '2':
                self.skipTest('REASON')
        self.assertGreater(5, int(operation))