How to use the nose2.discover function in nose2

To help you get started, we’ve selected a few nose2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sixty-north / cosmic-ray / plugins / test-runners / nose2 / cosmic_ray_nose2_runner / runner.py View on Github external
def _run(self):
        argv = ['']
        argv += self.test_args.split()
        collector = Nose2ResultsCollector()

        with open(os.devnull, 'w') as devnull:
            with redirect_stdout(devnull):
                with redirect_stderr(devnull):
                    nose2.discover(argv=argv, extraHooks=[('testOutcome', collector)], exit=False)
        failures = [x for x in collector.events if x.outcome != 'passed']

        return (not failures, [(str(r.test), traceback.format_exception(*r.exc_info)) for r in failures])
github fabiogibson / django-livesync / runtests.py View on Github external
* http://nose.readthedocs.org/en/latest/usage.html#basic-usage
"""
import os
import sys

import nose2
import django
from django.conf import settings


if __name__ == '__main__':
    settings.configure()
    django.setup()
    settings.BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    settings.DJANGO_LIVESYNC = {'PORT': 9001, 'HOST': '127.0.0.1'}
    result = nose2.discover()
    if not result:
        sys.exit(1)
github openwisp / netjsonconfig / runtests.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-

try:
    import nose2
except ImportError:
    message = """nose2 package not installed, install test requirements with:

    pip install -r requirements-test.txt
    """
    raise ImportError(message)

if __name__ == "__main__":
    result = nose2.discover()
    if result is False:
        import sys
        sys.exit(1)
github suoto / hdl_checker / .ci / scripts / run_tests.py View on Github external
test_env = os.environ.copy()

    test_env.update({"SERVER_LOG_LEVEL": args.log_level})

    home = p.join(os.environ["TOX_ENV_DIR"], "tmp", "home")
    os.makedirs(home)

    if not _ON_WINDOWS:
        test_env.update({"HOME": home})
    else:
        test_env.update({"LOCALAPPDATA": home})

    _logger.info("nose2 args: %s", nose_args)

    with mock.patch.dict("os.environ", test_env):
        successful = nose2.discover(exit=False, argv=nose_args).result.wasSuccessful()

    return successful
github david-cattermole / qt-learning / tests / runTests.py View on Github external
def runNose2():
    import nose2
    nose2.discover(exit=False)