Exemple #1
0
def run_tests(parser_args):
    import unittest
    import logging
    import settings
    settings.enable_test_mode()

    def unittest_main(test_runner=None):
        try:
            argv = [sys.argv[0]]
            if parser_args.extra_parameters:
                argv += parser_args.extra_parameters
            else:
                # workaround to avoid full unit test discovery
                # and limit test suite to settings.test_cases
                # argv.append('__main__.load_all_tests')
                argv.append('__main__.load_all_tests')

            unittest.main(module=None, argv=argv, testRunner=test_runner)
        except SystemExit as e:
            if e.code == 0:
                logging.info('PASS')
            else:
                logging.error('FAIL')
                raise

    if parser_args.pylint:
        from pylint import lint
        from pylint.reporters.text import ParseableTextReporter

        output = sys.stdout
        if parser_args.outfile:
            output = open(parser_args.outfile, 'w')

        config = "--rcfile=" + path.join(PROJECT_ROOT, 'pylint.rc')
        lint.Run([config] + settings.testable_modules,
                 reporter=ParseableTextReporter(output=output),
                 exit=False)

    elif parser_args.xunit:
        import xmlrunner

        output = 'reports'
        if parser_args.outfile:
            output = parser_args.outfile
        unittest_main(xmlrunner.XMLTestRunner(output=output))

    else:
        unittest_main(None)
Exemple #2
0
def run_tests(parser_args):
    import unittest
    import logging
    import settings
    settings.enable_test_mode()

    def unittest_main(test_runner=None):
        try:
            argv = [sys.argv[0]]
            if parser_args.extra_parameters:
                argv += parser_args.extra_parameters
            else:
                # workaround to avoid full unit test discovery
                # and limit test suite to settings.test_cases
                # argv.append('__main__.load_all_tests')
                argv.append('__main__.load_all_tests')

            unittest.main(module=None, argv=argv, testRunner=test_runner)
        except SystemExit as e:
            if e.code == 0:
                logging.info('PASS')
            else:
                logging.error('FAIL')
                raise

    if parser_args.pylint:
        from pylint import lint
        from pylint.reporters.text import ParseableTextReporter

        output = sys.stdout
        if parser_args.outfile:
            output = open(parser_args.outfile, 'w')

        config = "--rcfile=" + path.join(PROJECT_ROOT, 'pylint.rc')
        lint.Run([config] + settings.testable_modules,
                 reporter=ParseableTextReporter(output=output), exit=False)

    elif parser_args.xunit:
        import xmlrunner

        output = 'reports'
        if parser_args.outfile:
            output = parser_args.outfile
        unittest_main(xmlrunner.XMLTestRunner(output=output))

    else:
        unittest_main(None)
Exemple #3
0
def run_tests(options):
    import unittest
    import settings

    settings.enable_test_mode()
    argv = [sys.argv[0]] + args
    try:
        unittest.main(module=None, defaultTest='__main__.load_all_tests',
                      argv=argv)
    except SystemExit as e:
        from system.process_context import ProcessContext
        from constants import PROCESS_LAUNCH_PY

        logger = ProcessContext.get_logger(PROCESS_LAUNCH_PY)
        if e.code == 0:
            logger.info('PASS')
        else:
            logger.error('FAIL')
            raise
Exemple #4
0
def run_xunit(options):
    import unittest
    import xmlrunner
    import settings

    settings.enable_test_mode()

    output = 'reports'
    if options.outfile:
        output = options.outfile

    argv = [sys.argv[0]] + args
    try:
        unittest.main(module=None,
                      defaultTest='__main__.load_all_tests',
                      argv=argv,
                      testRunner=xmlrunner.XMLTestRunner(output=output))
    except SystemExit:
        pass
Exemple #5
0
def run_tests(options):
    import unittest
    import settings

    settings.enable_test_mode()

    argv = [sys.argv[0]] + args
    try:
        unittest.main(module=None, defaultTest='__main__.load_all_tests',
                      argv=argv)
    except SystemExit as e:
        from synergy.conf.process_context import ProcessContext
        from constants import PROCESS_LAUNCH_PY

        logger = ProcessContext.get_logger(PROCESS_LAUNCH_PY)
        if e.code == 0:
            logger.info('PASS')
        else:
            logger.error('FAIL')
            raise
Exemple #6
0
def run_xunit(options):
    import unittest
    import xmlrunner
    import settings

    settings.enable_test_mode()

    output = 'reports'
    if options.outfile:
        output = options.outfile

    argv = [sys.argv[0]] + args
    try:
        unittest.main(
            module=None,
            defaultTest='__main__.load_all_tests',
            argv=argv,
            testRunner=xmlrunner.XMLTestRunner(output=output))
    except SystemExit:
        pass
__author__ = 'Bohdan Mushkevych'

import mock
import types
import unittest

from settings import enable_test_mode
enable_test_mode()

import process_starter
from six import class_types, PY2, PY3


def main_function(*args):
    return args


class OldClass:
    def starter_method(self, *args):
        return args


class NewClass(object):
    def starter_method(self, *args):
        return args


class TestProcessStarter(unittest.TestCase):
    def test_type_old_class(self):
        t, m, starter = process_starter.get_class('tests.test_process_starter.OldClass')
        self.assertIn(t, class_types)
Exemple #8
0
__author__ = 'Bohdan Mushkevych'

import unittest
from settings import enable_test_mode

enable_test_mode()

from db.model.raw_data import DOMAIN_NAME, TIMEPERIOD
from constants import PROCESS_SITE_HOURLY
from tests import hourly_fixtures
from tests.test_abstract_worker import AbstractWorkerUnitTest
from workers.site_hourly_aggregator import SiteHourlyAggregator


class SiteHourlyAggregatorUnitTest(AbstractWorkerUnitTest):
    def virtual_set_up(self):
        super(SiteHourlyAggregatorUnitTest,
              self).constructor(baseclass=SiteHourlyAggregator,
                                process_name=PROCESS_SITE_HOURLY,
                                output_prefix='EXPECTED_SITE_HOURLY',
                                output_module=hourly_fixtures,
                                generate_output=False,
                                compare_results=True)
        hourly_fixtures.clean_session_entries()
        return hourly_fixtures.generated_session_entries()

    def virtual_tear_down(self):
        hourly_fixtures.clean_session_entries()

    def _get_key(self, obj):
        return obj[DOMAIN_NAME], obj[TIMEPERIOD]
 def setUpClass(cls):
     import settings as module_settings
     module_settings.enable_test_mode()
Exemple #10
0
 def setUpClass(cls):
     settings_module.enable_test_mode()
     super(TestTreeNode, cls).setUpClass()
 def setUpClass(cls):
     super(GarbageCollectorUnitTest, cls).setUpClass()
     module_settings.enable_test_mode()