Example #1
0
            num_cores = 4  # Guess
        args = ['--nocapture', '--stop', '--processes=%s' % num_cores]
    else:
        # Some args/options specified.  Check to see if any nose options have
        # been specified.  If they have, then don't set any
        has_options = any(map(lambda x: x.startswith('--'), args))
        if not has_options:
            # Default options:
            # --stop Abort on first error/failure
            # --nocapture Don't capture STDOUT
            args.extend(['--nocapture', '--stop'])
        else:
            # Remove options as nose will pick these up from sys.argv
            for arg in args:
                if arg.startswith('--verbosity'):
                    verbosity = int(arg[-1])
            args = [arg for arg in args if not arg.startswith('-')]

    configure()
    with warnings.catch_warnings():
        # The warnings module in default configuration will never cause tests
        # to fail, as it never raises an exception.  We alter that behaviour by
        # turning DeprecationWarnings into exceptions, but exclude warnings
        # triggered by third-party libs. Note: The context manager is not thread
        # safe. Behaviour with multiple threads is undefined.
        warnings.filterwarnings('error', category=DeprecationWarning)
        warnings.filterwarnings('error', category=RuntimeWarning)
        libs = r'(sorl\.thumbnail.*|bs4.*|webtest.*)'
        warnings.filterwarnings('ignore', r'.*', DeprecationWarning, libs)
        run_tests(verbosity, *args)
Example #2
0
#!/usr/bin/env python
import sys
import logging
from optparse import OptionParser
from coverage import coverage

# This configures the settings
from tests.config import configure
configure()

from django_nose import NoseTestSuiteRunner

logging.disable(logging.CRITICAL)


def run_tests(verbosity, *test_args):
    test_runner = NoseTestSuiteRunner(verbosity=verbosity)
    if not test_args:
        test_args = ['tests']
    num_failures = test_runner.run_tests(test_args)
    if num_failures:
        sys.exit(num_failures)


if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option('-c', '--coverage', dest='use_coverage', default=False,
                      action='store_true', help="Generate coverage report")
    parser.add_option('-v', '--verbosity', dest='verbosity', default=1,
                      type='int', help="Verbosity of output")
    (options, args) = parser.parse_args()
#!/usr/bin/env python
import logging
import sys

from optparse import OptionParser
from tests.config import configure

logging.disable(logging.CRITICAL)


def run_tests(*test_args):
    from django_nose import NoseTestSuiteRunner
    test_runner = NoseTestSuiteRunner()
    if not test_args:
        test_args = ['tests']
    num_failures = test_runner.run_tests(test_args)
    if num_failures:
        sys.exit(num_failures)

if __name__ == '__main__':
    parser = OptionParser()
    __, args = parser.parse_args()
    configure(nose_args=['-s', '-x', '--with-spec'])
    run_tests(*args)
Example #4
0
        sys.exit(num_failures)


if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option('--with-coverage', dest='coverage', default=False,
                      action='store_true')
    parser.add_option('--with-xunit', dest='xunit', default=False,
                      action='store_true')
    parser.add_option('--collect-only', dest='collect', default=False,
                      action='store_true')
    options, args = parser.parse_args()

    if options.collect:
        # Show tests only so a bash autocompleter can use the results
        configure(['-v'])
        run_tests()
    else:
        # If no args, then use 'progressive' plugin to keep the screen real
        # estate used down to a minimum.  Otherwise, use the spec plugin
        nose_args = ['-s', '-x']
        if args:
            nose_args.extend(['--with-specplugin'])
        else:
            nose_args.append('--with-progressive')

        if options.coverage:
            # Nose automatically uses any options passed to runtests.py, which
            # is why the coverage trigger uses '--with-coverage' and why we
            # don't need to explicitly include it here.
            nose_args.extend([
Example #5
0
#!/usr/bin/env python
import logging
import sys

from optparse import OptionParser
from tests.config import configure

logging.disable(logging.CRITICAL)


def run_tests(*test_args):
    from django_nose import NoseTestSuiteRunner
    test_runner = NoseTestSuiteRunner()
    if not test_args:
        test_args = ['tests']
    num_failures = test_runner.run_tests(test_args)
    if num_failures:
        sys.exit(num_failures)


if __name__ == '__main__':
    parser = OptionParser()
    __, args = parser.parse_args()
    configure(nose_args=['-s', '-x', '--with-spec'])
    run_tests(*args)
Example #6
0
    test_runner = NoseTestSuiteRunner()
    if not test_args:
        test_args = ['tests']
    num_failures = test_runner.run_tests(test_args)
    if num_failures:
        sys.exit(num_failures)


if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option('--with-coverage', dest='coverage', default=False,
                      action='store_true')
    parser.add_option('--with-xunit', dest='xunit', default=False,
                      action='store_true')
    options, args = parser.parse_args()

    # If no args, then use 'progressive' plugin to keep the screen real estate
    # used down to a minimum.  Otherwise, use the spec plugin
    nose_args = ['-s', '-x',
                 '--with-progressive' if not args else '--with-spec']

    if options.coverage:
        # Nose automatically uses any options passed to runtests.py, which is
        # why the coverage trigger uses '--with-coverage' and why we don't need
        # to explicitly include it here.
        nose_args.extend([
            '--cover-package=oscar', '--cover-html',
            '--cover-html-dir=htmlcov'])
    configure(nose_args)
    run_tests(*args)
Example #7
0
def before_all(context):
    from tests.config import configure
    configure()

    from django.test import utils
    utils.setup_test_environment()