mardi 4 juin 2019

Skip Python tests if app version is less than 1.5.5

I've got a test class with 25 tests. There are 12 tests that I only want to run if my application version is greater than 1.5.5.

I think I could add an if to each affected test to check the version is greater than 1.5.5. something like this:

def test_to_skip(self):
    if StrictVersion(app_version) > StrictVersion('1.5.5'):
        self.skipTest('skipped test as feature is not available in this version')
    else:
        execute_test

This would create a lot of code duplication.

Is there any better way to do this so I can avoid the duplication?

Aucun commentaire:

Enregistrer un commentaire