Ejemplo n.º 1
0
    def setUp(self):
        self.xmlfile = os.path.abspath(
            os.path.join(os.path.dirname(__file__), 'support', 'xunit.xml'))
        parser = optparse.OptionParser()
        self.x = Xunit()
        self.x.add_options(parser, env={})
        (options, args) = parser.parse_args(
            ["--with-xunit", "--xunit-file=%s" % self.xmlfile])
        self.x.configure(options, Config())

        try:
            import xml.etree.ElementTree
        except ImportError:
            self.ET = False
        else:
            self.ET = xml.etree.ElementTree
Ejemplo n.º 2
0
class TestUndecoratedFunctionalXunit(NoseDepPluginTester):
    # Initially there was a bug causing Xunit to fail in
    # combination with nosedep. This test verifies that it works.
    args = ['-v', '--with-xunit']
    plugins = [NoseDep(), Xunit()]
    suitepath = "test_scripts/undecorated_functional_tests.py:"

    def setUp(self):
        if os.path.isfile('nosetests.xml'):
            os.remove('nosetests.xml')
        super(TestUndecoratedFunctionalXunit, self).setUp()

    def tearDown(self):
        with open('nosetests.xml') as xml:
            assert_in('tests="2"', xml.read())
        super(TestUndecoratedFunctionalXunit, self).tearDown()

    def runTest(self):
        self.check([
            'test_scripts.undecorated_functional_tests.test_x ... ok',
            'test_scripts.undecorated_functional_tests.test_y ... ERROR'
        ])
Ejemplo n.º 3
0
class SynchroModuleFinder(object):
    def find_module(self, fullname, path=None):
        for module_name in pymongo_modules:
            if fullname.endswith(module_name):
                return SynchroModuleLoader(path)

        # Let regular module search continue.
        return None


class SynchroModuleLoader(object):
    def __init__(self, path):
        self.path = path

    def load_module(self, fullname):
        return synchro


if __name__ == '__main__':
    # Monkey-patch all pymongo's unittests so they think Synchro is the
    # real PyMongo.
    sys.meta_path[0:0] = [SynchroModuleFinder()]

    # Ensure time.sleep() acts as PyMongo's tests expect: background tasks
    # can run to completion while foreground pauses.
    sys.modules['time'] = synchro.TimeModule()

    nose.main(config=Config(plugins=PluginManager()),
              addplugins=[SynchroNosePlugin(),
                          Skip(), Xunit()])
Ejemplo n.º 4
0
 def test_file_from_opt(self):
     parser = optparse.OptionParser()
     x = Xunit()
     x.add_options(parser, env={})
     (options, args) = parser.parse_args(["--xunit-file=blagojevich.xml"])
     eq_(options.xunit_file, "blagojevich.xml")
Ejemplo n.º 5
0
 def test_file_from_environ(self):
     parser = optparse.OptionParser()
     x = Xunit()
     x.add_options(parser, env={'NOSE_XUNIT_FILE': "kangaroo.xml"})
     (options, args) = parser.parse_args([])
     eq_(options.xunit_file, "kangaroo.xml")
Ejemplo n.º 6
0
 def test_defaults(self):
     parser = optparse.OptionParser()
     x = Xunit()
     x.add_options(parser, env={})
     (options, args) = parser.parse_args([])
     eq_(options.xunit_file, "nosetests.xml")
Ejemplo n.º 7
0
        "--tolerance",
        dest="tolerance",
        default=None,
        metavar='int',
        help="tolerance for relative precision in comparison (trumps strict)")

    all_strict = ['high', 'medium', 'low']
    parser.add_option("",
                      "--strict",
                      dest="strict",
                      default='low',
                      metavar='str',
                      help="strictness for testing precision: [%s]" %
                      " ,".join(all_strict))

    xunit_plugin = Xunit()
    # Make sure this plugin get called by setting its score to be the highest.
    xunit_plugin.score = 1000000
    xunit_plugin.enabled = True

    # Set up a dummy env for xunit to parse. Note we are using nose's xunit,
    # not the one bundled in yt
    env = {"NOSE_XUNIT_FILE": "nosetests.xml"}
    xunit_plugin.options(parser, env)

    answer_plugin = AnswerTesting()
    answer_plugin.enabled = True
    answer_plugin.options(parser)
    reporting_plugin = ResultsSummary()
    reporting_plugin.enabled = True
    pdb_plugin = debug.Pdb()
Ejemplo n.º 8
0
if __name__ == '__main__':
    # Monkey-patch all pymongo's unittests so they think Synchro is the
    # real PyMongo.
    sys.meta_path[0:0] = [SynchroModuleFinder()]

    # Ensure time.sleep() acts as PyMongo's tests expect: background tasks
    # can run to completion while foreground pauses.
    sys.modules['time'] = synchro.TimeModule()

    if '--check-exclude-patterns' in sys.argv:
        check_exclude_patterns = True
        sys.argv.remove('--check-exclude-patterns')
    else:
        check_exclude_patterns = False

    success = nose.run(
        config=Config(plugins=PluginManager()),
        addplugins=[SynchroNosePlugin(), Skip(), Xunit()])

    if not success:
        sys.exit(1)

    if check_exclude_patterns:
        unused_module_pats = set(excluded_modules) - excluded_modules_matched
        assert not unused_module_pats, "Unused module patterns: %s" % (
            unused_module_pats, )

        unused_test_pats = set(excluded_tests) - excluded_tests_matched
        assert not unused_test_pats, "Unused test patterns: %s" % (
            unused_test_pats, )
Ejemplo n.º 9
0
        # we want all directories
        return True

    def find_examples(self, name):
        examples = []
        if os.path.isdir(name):
            for subname in os.listdir(name):
                examples.extend(self.find_examples(os.path.join(name,
                                                                subname)))
            return examples
        elif name.endswith('.py'):  # only execute Python scripts
            return [name]
        else:
            return []

    def loadTestsFromName(self, name, module=None, discovered=False):
        all_examples = self.find_examples(name)
        all_tests = []
        for target in ['numpy']:
            for example in all_examples:
                all_tests.append(RunTestCase(example, target))
        return all_tests


if __name__ == '__main__':
    argv = [
        __file__, '-v', '--with-xunit', '--verbose', '--exe', '../../examples'
    ]

    nose.main(argv=argv, plugins=[SelectFilesPlugin(), Capture(), Xunit()])
Ejemplo n.º 10
0
 def setUp(self):
     self.x = Xunit()
Ejemplo n.º 11
0
    # Monkey-patch all pymongo's unittests so they think Synchro is the
    # real PyMongo.
    sys.meta_path[0:0] = [SynchroModuleFinder()]

    # Ensure time.sleep() acts as PyMongo's tests expect: background tasks
    # can run to completion while foreground pauses.
    sys.modules['time'] = synchro.TimeModule()

    if '--check-exclude-patterns' in sys.argv:
        check_exclude_patterns = True
        sys.argv.remove('--check-exclude-patterns')
    else:
        check_exclude_patterns = False

    success = nose.run(config=Config(plugins=PluginManager()),
                       addplugins=[SynchroNosePlugin(),
                                   Skip(),
                                   Xunit()])

    if not success:
        sys.exit(1)

    if check_exclude_patterns:
        unused_module_pats = set(excluded_modules) - excluded_modules_matched
        assert not unused_module_pats, "Unused module patterns: %s" % (
            unused_module_pats, )

        unused_test_pats = set(excluded_tests) - excluded_tests_matched
        assert not unused_test_pats, "Unused test patterns: %s" % (
            unused_test_pats, )
Ejemplo n.º 12
0
def run_test():
    nose.main(addplugins=[
        AutoTestRunner(),
        AttributeSelector(),
        Xunit(), Coverage()
    ])
Ejemplo n.º 13
0
import sys
import nose
import os
import glob
from nose.plugins import Plugin
from nose.plugins.multiprocess import MultiProcess
from nose.plugins.xunit import Xunit
# http://nose.readthedocs.io/en/latest/doc_tests/test_multiprocess/multiprocess.html

#from nose_xunitmp import XunitMP

if __name__ == "__main__":

    args = [
        "-v",
        "--with-xunit",
        "--xunit-file=results.xml",
        #"--with-xunitmp",
        #"--xunitmp-file=results.xml",
        "--processes=10",  # parallel tests
        "--process-timeout=120"  # parallel tests
    ]

    if sys.argv[1:]:
        args.extend(sys.argv[1:])
    else:
        args.extend(glob.glob(os.path.join("tests", "*_test.py")))

    nose.run(argv=args, plugins=[MultiProcess(), Xunit()])
    #nose.run(argv=args, plugins=[MultiProcess(), XunitMP()])
Ejemplo n.º 14
0
                # print preferences (setting happens in RunTestCase.runTest())
                utils.print_single_prefs(prefs_dict, set_prefs=prefs)
            else:  # None
                print(f"Running {target} with default preferences")
                # RunTestCase.runTest() needs a dictionary
                prefs_dict = {}

            image_dir = os.path.join(target_image_dir,
                                     utils.dict_to_name(prefs_dict))

            success = nose.run(argv=argv,
                               plugins=[
                                   SelectFilesPlugin(target_list, image_dir,
                                                     prefs_dict),
                                   Capture(),
                                   Xunit()
                               ])
            successes.append(success)

        print(f"\nTARGET: {target.upper()}")
        all_success = utils.check_success(successes, all_prefs_combinations)

        all_successes.append(all_success)

    if len(args.targets) > 1:
        print("\nFINISHED ALL TARGETS")

        if all(all_successes):
            print("\nALL TARGETS PASSED")
        else:
            print("\n{}/{} TARGETS FAILED:".format(
Ejemplo n.º 15
0
def main():
    parser = argparse.ArgumentParser(description="Integration test suite")
    parser.add_argument("-i",
                        "--iso",
                        dest="iso",
                        help="iso image path or http://url")
    parser.add_argument("-l",
                        "--level",
                        dest="log_level",
                        type=str,
                        help="log level",
                        choices=["DEBUG", "INFO", "WARNING", "ERROR"],
                        default="ERROR",
                        metavar="LEVEL")
    parser.add_argument('--no-forward-network',
                        dest='no_forward_network',
                        action="store_true",
                        default=False,
                        help='do not forward environment netork')
    parser.add_argument('--export-logs-dir',
                        dest='export_logs_dir',
                        type=str,
                        help='directory to save fuelweb logs')
    parser.add_argument('--installation-timeout',
                        dest='installation_timeout',
                        type=int,
                        help='admin node installation timeout')
    parser.add_argument('--deployment-timeout',
                        dest='deployment_timeout',
                        type=int,
                        help='admin node deployment timeout')
    parser.add_argument('--suite',
                        dest='test_suite',
                        type=str,
                        help='Test suite to run',
                        choices=["integration"],
                        default="integration")
    parser.add_argument('--environment',
                        dest='environment',
                        type=str,
                        help='Environment name',
                        default="integration")
    parser.add_argument('command',
                        choices=('setup', 'destroy', 'test'),
                        default='test',
                        help="command to execute")
    parser.add_argument('arguments',
                        nargs=argparse.REMAINDER,
                        help='arguments for nose testing framework')

    params = parser.parse_args()

    numeric_level = getattr(logging, params.log_level.upper())
    logging.basicConfig(level=numeric_level)
    paramiko_logger = logging.getLogger('paramiko')
    paramiko_logger.setLevel(numeric_level + 1)

    suite = fuelweb_test.integration

    #   todo fix default values
    if params.no_forward_network:
        ci = suite.Ci(params.iso, forward=None, env_name=params.environment)
    else:
        ci = suite.Ci(params.iso, env_name=params.environment)

    if params.export_logs_dir is not None:
        ci.export_logs_dir = params.export_logs_dir

    if params.deployment_timeout is not None:
        ci.deployment_timeout = params.deployment_timeout

    if params.command == 'setup':
        result = ci.setup_environment()
    elif params.command == 'destroy':
        result = ci.destroy_environment()
    elif params.command == 'test':
        import nose
        import nose.config

        nc = nose.config.Config()
        nc.verbosity = 3
        nc.plugins = PluginManager(plugins=[Xunit()])
        # Set folder where to process tests
        nc.configureWhere(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         params.test_suite))

        suite.ci = ci
        nose.main(
            module=suite,
            config=nc,
            argv=[__file__, "--with-xunit", "--xunit-file=nosetests.xml"] +
            params.arguments)
        result = True
    else:
        print("Unknown command '%s'" % params.command)
        sys.exit(1)

    if not result:
        sys.exit(1)
Ejemplo n.º 16
0
        "pymongo.change_stream",
        "pymongo.cursor",
        "pymongo.encryption",
        "pymongo.encryption_options",
        "pymongo.mongo_client",
        "pymongo.database",
        "gridfs",
        "gridfs.grid_file",
    ]:
        sys.modules.pop(n)

    if "--check-exclude-patterns" in sys.argv:
        check_exclude_patterns = True
        sys.argv.remove("--check-exclude-patterns")
    else:
        check_exclude_patterns = False

    success = nose.run(
        config=Config(plugins=PluginManager()), addplugins=[SynchroNosePlugin(), Skip(), Xunit()]
    )

    if not success:
        sys.exit(1)

    if check_exclude_patterns:
        unused_module_pats = set(excluded_modules) - excluded_modules_matched
        assert not unused_module_pats, "Unused module patterns: %s" % (unused_module_pats,)

        unused_test_pats = set(excluded_tests) - excluded_tests_matched
        assert not unused_test_pats, "Unused test patterns: %s" % (unused_test_pats,)