Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distribute and execute platform-specific unit tests?

We have a python project that we want to start testing using buildbot. Its unit tests include tests that should only work on some platforms. So, we've got tests that should pass on all platforms, tests that should only run on 1 specific platform, tests that should pass on platforms A, B, C and tests that pass on B and D.

What is the best way of doing this? Simple suites would be a hassle, since, as described, each test can have a different list of target platforms. I thought about adding "@run_on" and "@ignore_on" decorators that would match platforms to test methods. Is there anything better?

like image 351
abyx Avatar asked Nov 06 '22 20:11

abyx


1 Answers

On a couple of occasions I have used this very simple approach in test modules:

import sys
import unittest

if 'win' in sys.platform:
    class TestIt(unittest.TestCase):
        ...

if 'linux' in sys.platform:
    class TestIt(unittest.TestCase):
        ...
like image 87
codeape Avatar answered Nov 14 '22 23:11

codeape