python_suite.py 1.46 KB
Newer Older
1 2 3
"""
Classes used for defining and running python test suites
"""
4 5
import os

6
from pavelib.utils.test import utils as test_utils
7
from pavelib.utils.test.suites.suite import TestSuite
8
from pavelib.utils.test.suites.pytest_suite import LibTestSuite, SystemTestSuite
9 10 11 12 13 14 15 16 17 18 19
from pavelib.utils.envs import Env

__test__ = False  # do not collect


class PythonTestSuite(TestSuite):
    """
    A subclass of TestSuite with extra setup for python tests
    """
    def __init__(self, *args, **kwargs):
        super(PythonTestSuite, self).__init__(*args, **kwargs)
20
        self.opts = kwargs
21
        self.disable_migrations = kwargs.get('disable_migrations', True)
22 23 24 25 26
        self.fasttest = kwargs.get('fasttest', False)
        self.subsuites = kwargs.get('subsuites', self._default_subsuites)

    def __enter__(self):
        super(PythonTestSuite, self).__enter__()
27 28 29 30

        if self.disable_migrations:
            os.environ['DISABLE_MIGRATIONS'] = '1'

31
        if not (self.fasttest or self.skip_clean):
32 33 34 35 36 37 38 39 40
            test_utils.clean_test_files()

    @property
    def _default_subsuites(self):
        """
        The default subsuites to be run. They include lms, cms,
        and all of the libraries in common/lib.
        """
        lib_suites = [
41
            LibTestSuite(d, **self.opts) for d in Env.LIB_TEST_DIRS
42 43 44
        ]

        system_suites = [
45 46
            SystemTestSuite('cms', **self.opts),
            SystemTestSuite('lms', **self.opts),
47 48 49
        ]

        return system_suites + lib_suites