Exemplo n.º 1
0
    def do_nose(self):
        t0 = time.time()
        print "do nose"
        dp = DataPlugin(self.forkr._data)
        noseConfig = nose.config.Config(showPlugins=True,
                                        #debug =99,
                                        )
        #noseConfig.testMatchPat = 'Tests|_test'
        #noseConfig.verbosity = 9999
        #sys.exit(0 if nose.run() else 1)

        testRunner = nose.core.TextTestRunner(  #stream=self.config.stream,
            config=noseConfig,
            #verbosity=1000, #self.config.verbosity,
            #config=self.config
        )
        t = TestProgram(
            testRunner=testRunner,
            #config=noseConfig,
            plugins=[
                dp,
            ],
        )
        t.runTests()
        t1 = time.time()

        total_n = t1 - t0
        print("took total", total_n)
Exemplo n.º 2
0
    def run(self):
        for env_name, env_value in self.extra_env.items():
            os.environ[env_name] = str(env_value)

        setup_dir = os.path.abspath(os.path.dirname(__file__))
        tests_dir = os.path.join(setup_dir, 'nosedjangotests')
        os.chdir(tests_dir)
        sys.path.append(tests_dir)

        try:
            from nose.core import TestProgram
            import nosedjango
        except ImportError:
            print 'nose and nosedjango are required to run this test suite'
            sys.exit(1)

        print "Running tests with sqlite"
        args = [
            '-v',
            '--with-doctest',
            '--with-django',
            '--django-settings',
            'nosedjangotests.settings',
            '--django-sqlite',
            'nosedjangotests.polls',
        ]
        TestProgram(argv=args, exit=False)

        print "Running tests multiprocess"
        args = [
            '-v',
            '--with-doctest',
            '--processes',
            '3',
            '--with-django',
            '--django-settings',
            'nosedjangotests.settings',
            '--django-sqlite',
            'nosedjangotests.polls',
        ]
        TestProgram(argv=args, exit=False)

        print "Running tests with mysql. (will fail if mysql not configured)"
        args = [
            '-v',
            '--with-id',
            '--with-doctest',
            '--with-django',
            '--django-settings',
            'nosedjangotests.settings',
            'nosedjangotests.polls',
        ]
        TestProgram(argv=args, exit=False)

        os.chdir(setup_dir)
Exemplo n.º 3
0
    def test_run_support_package3(self):
        """Collect and run tests in functional_tests/support/package3

        This should collect and run 2 test. The package layout is:

        lib/
          a.py
        src/
          b.py
        tests/
          test_a.py
          test_b.py
        """
        stream = StringIO()
        runner = TestRunner(stream=stream)

        prog = TestProgram(defaultTest=os.path.join(support, 'package3'),
                           argv=['test_run_support_package3', '-v'],
                           testRunner=runner,
                           config=Config(),
                           exit=False)
        res = runner.result
        print
        stream.getvalue()
        self.assertEqual(res.testsRun, 2,
                         "Expected to run 2 tests, ran %s" % res.testsRun)
        assert res.wasSuccessful()
        assert not res.errors
        assert not res.failures
Exemplo n.º 4
0
    def test_run_support_twist(self):
        """Collect and run tests in functional/support/twist

        This should collect and run 4 tests with 2 fails and an error.
        """
        try:
            from twisted.trial.unittest import TestCase
        except ImportError:
            raise SkipTest('twisted not available; skipping')
        stream = StringIO()
        runner = TestRunner(stream=stream, verbosity=2)

        prog = TestProgram(defaultTest=os.path.join(support, 'twist'),
                           argv=['test_run_support_twist'],
                           testRunner=runner,
                           config=Config(stream=stream),
                           exit=False)
        res = runner.result
        print stream.getvalue()
        print "-----"
        print repr(res)

        self.assertEqual(res.testsRun, 4,
                         "Expected to run 4 tests, ran %s" % (res.testsRun, ))
        assert not res.wasSuccessful()
        assert len(res.errors) == 1

        # In 12.3, Twisted made their skip functionality match unittests, so the
        # skipped test is no longer reported as a failure.
        import twisted
        v = twisted.version
        if (v.major, v.minor) >= (12, 3):
            assert len(res.failures) == 1
        else:
            assert len(res.failures) == 2
Exemplo n.º 5
0
def process_args():
  tests = []

  opts = None
  if sys.argv[-1].startswith("-"):
    test_names = sys.argv[1:-1]
    opts = sys.argv[-1]
  else:
    test_names = sys.argv[1:]

  for arg in test_names:
    arg = arg.strip()
    if len(arg) == 0:
      return

    a = arg.split("::")
    if len(a) == 1:
      # From module or folder
      a_splitted = a[0].split(";")
      if len(a_splitted) != 1:
        # means we have pattern to match against
        if a_splitted[0].endswith("/"):
          debug("/ from folder " + a_splitted[0] + ". Use pattern: " + a_splitted[1])
          tests.append(a_splitted[0])
      else:
        if a[0].endswith("/"):
          debug("/ from folder " + a[0])
          tests.append(a[0])
        else:
          debug("/ from module " + a[0])
          tests.append(a[0])

    elif len(a) == 2:
      # From testcase
      debug("/ from testcase " + a[1] + " in " + a[0])
      tests.append(a[0] + ":" + a[1])
    else:
      # From method in class or from function
      debug("/ from method " + a[2] + " in testcase " +  a[1] + " in " + a[0])
      if a[1] == "":
        # test function, not method
        tests.append(a[0] + ":" + a[2])
      else:
        tests.append(a[0] + ":" + a[1] + "." + a[2])

  argv = ['nosetests']

  argv.extend(tests)


  if opts:
    options = shlex.split(opts)
    argv.extend(options)

  manager = DefaultPluginManager()
  manager.addPlugin(teamcity_plugin)
  config = MyConfig(plugins=manager)
  config.configure(argv)

  TestProgram(argv=argv, config=config, exit=False)
def autohelp_directive(dirname, arguments, options, content, lineno,
                       content_offset, block_text, state, state_machine):
    """produces rst from nose help"""
    config = Config(parserClass=OptBucket, plugins=BuiltinPluginManager())
    parser = config.getParser(TestProgram.usage())
    rst = ViewList()
    for line in parser.format_help().split('\n'):
        rst.append(line, '<autodoc>')

    rst.append('Options', '<autodoc>')
    rst.append('-------', '<autodoc>')
    rst.append('', '<autodoc>')
    for opt in parser:
        rst.append(opt.options(), '<autodoc>')
        rst.append('   \n', '<autodoc>')
        rst.append('   ' + opt.help + '\n', '<autodoc>')
        rst.append('\n', '<autodoc>')
    node = nodes.section()
    node.document = state.document
    surrounding_title_styles = state.memo.title_styles
    surrounding_section_level = state.memo.section_level
    state.memo.title_styles = []
    state.memo.section_level = 0
    state.nested_parse(rst, 0, node, match_titles=1)
    state.memo.title_styles = surrounding_title_styles
    state.memo.section_level = surrounding_section_level

    return node.children
Exemplo n.º 7
0
        def run(self):
            """ensure tests are capable of being run, then
            run nose.main with a reconstructed argument list"""
            self.run_command('egg_info')

            # Build extensions in-place
            self.reinitialize_command('build_ext', inplace=1)
            self.run_command('build_ext')

            if self.distribution.install_requires:
                self.distribution.fetch_build_eggs(
                    self.distribution.install_requires)
            if self.distribution.tests_require:
                self.distribution.fetch_build_eggs(
                    self.distribution.tests_require)

            argv = ['nosetests']
            for (option_name, cmd_name) in self.option_to_cmds.items():
                if option_name in option_blacklist:
                    continue
                value = getattr(self, option_name)
                if value is not None:
                    argv.extend(
                        self.cfgToArg(option_name.replace('_', '-'), value))
            TestProgram(argv=argv, config=self.__config)
Exemplo n.º 8
0
def test_gpu():
    ctx = mx.gpu(0)
    mx.test_utils.set_default_context(ctx)
    assert mx.current_context() == ctx
    path = os.path.join(os.path.dirname(__file__), '../')
    TestProgram(defaultTest=path, argv=[path, '-s'], exit=False)
    assert mx.current_context() == ctx
Exemplo n.º 9
0
def autohelp_directive(dirname, arguments, options, content, lineno,
                       content_offset, block_text, state, state_machine):
    """produces rst from nose help"""
    config = Config(parserClass=OptBucket,
                    plugins=BuiltinPluginManager())
    parser = config.getParser(TestProgram.usage())
    rst = ViewList()
    for line in parser.format_help().split('\n'):
        rst.append(line, '<autodoc>')

    rst.append('Options', '<autodoc>')
    rst.append('-------', '<autodoc>')
    rst.append('', '<autodoc>')
    for opt in parser:
        rst.append(opt.options(), '<autodoc>')
        rst.append('   \n', '<autodoc>')
        rst.append('   ' + opt.help + '\n', '<autodoc>')
        rst.append('\n', '<autodoc>')    
    node = nodes.section()
    node.document = state.document
    surrounding_title_styles = state.memo.title_styles
    surrounding_section_level = state.memo.section_level
    state.memo.title_styles = []
    state.memo.section_level = 0
    state.nested_parse(rst, 0, node, match_titles=1)
    state.memo.title_styles = surrounding_title_styles
    state.memo.section_level = surrounding_section_level

    return node.children
Exemplo n.º 10
0
    def test_run_support_twist(self):
        """Collect and run tests in functional/support/twist

        This should collect and run 4 tests with 2 fails and an error.
        """
        try:
            from twisted.trial.unittest import TestCase
        except ImportError:
            raise SkipTest('twisted not available; skipping')
        stream = StringIO()
        runner = TestRunner(stream=stream, verbosity=2)

        prog = TestProgram(defaultTest=os.path.join(support, 'twist'),
                           argv=['test_run_support_twist'],
                           testRunner=runner,
                           config=Config(stream=stream),
                           exit=False)
        res = runner.result
        print stream.getvalue()

        # some versions of twisted.trial.unittest.TestCase have
        # runTest in the base class -- this is wrong! But we have
        # to deal with it
        if hasattr(TestCase, 'runTest'):
            expect = 5
        else:
            expect = 4
        self.assertEqual(
            res.testsRun, expect,
            "Expected to run %s tests, ran %s" % (expect, res.testsRun))
        assert not res.wasSuccessful()
        assert len(res.errors) == 1
        assert len(res.failures) == 2
Exemplo n.º 11
0
    def test_issue_130(self):
        """Collect and run tests in support/issue130 without error.

        This tests that the result and error classes can handle string
        exceptions.
        """
        import warnings
        warnings.filterwarnings('ignore',
                                category=DeprecationWarning,
                                module='test')

        stream = StringIO()
        runner = TestRunner(stream=stream, verbosity=2)

        prog = TestProgram(defaultTest=os.path.join(support, 'issue130'),
                           argv=['test_issue_130'],
                           testRunner=runner,
                           config=Config(stream=stream,
                                         plugins=DefaultPluginManager()),
                           exit=False)
        res = runner.result
        print
        stream.getvalue()
        self.assertEqual(res.testsRun, 0)  # error is in setup
        assert not res.wasSuccessful()
        assert res.errors
        assert not res.failures
Exemplo n.º 12
0
    def run(self):
        for env_name, env_value in self.extra_env.items():
            os.environ[env_name] = str(env_value)

        setup_dir = os.path.abspath(os.path.dirname(__file__))
        tests_dir = os.path.join(setup_dir, 'testproj')
        os.chdir(tests_dir)
        sys.path.append(tests_dir)

        try:
            from nose.core import TestProgram
        except ImportError:
            print 'nose is required to run this test suite'
            sys.exit(1)

        print "Mixpanel %s test suite running (Python %s)..." % (
            mixpanel.__version__, sys.version.split()[0])
        args = [
            '-v',
            '--with-id',
            '--with-doctest',
            '--with-coverage',
            '--cover-erase',
            '--cover-package',
            'mixpanel',
            'mixpanel',
        ]
        TestProgram(argv=args, exit=False)

        os.chdir(setup_dir)
        rabbitmq_msg = "Rabbitmq must be configured with a '/' vhost and "
        rabbitmq_msg += "username/password of 'guest' for all tests to pass"
        print rabbitmq_msg
Exemplo n.º 13
0
    def _perform_one_test(self, directories, results_queue, address):
        try:
            print("start test run")
            null_device = open('/dev/null')
            os.stdin = null_device
            select = SelectOneTestAndStoreOutput(address)
            plugins = [select, Skip()]
            argv = ['nose']
            argv.extend(directories)
            result = TestProgram(exit=False, argv=argv, plugins=plugins)
            success = result.success
            if success:
                result = 'Success'
            else:
                result = 'Failure'

            if select.buffer:
                result += ' - '
                if len(select.buffer) > 1000:
                    result += select.buffer[:min(1000, len(result) - 1)]
                    result += ' ' + str(result - 1000) + ' more ...'
                else:
                    result += select.buffer

            results_queue.put(('test-output', result))
        except:
            results_queue.put((
                'test-error',
                'Exception happened: ' + str(sys.exc_info()[0]) + " - " +
                str(sys.exc_info()[1]),
            ))
        finally:
            results_queue.put(None)
            MPI.Finalize()
            print("calling finalize done")
Exemplo n.º 14
0
    def test_plugin_calls_package1_verbose(self):
        wdir = os.path.join(support, 'package1')
        man = RecordingPluginManager()
        conf = Config(plugins=man, stream=sys.stdout)
        t = TestProgram(defaultTest=wdir,
                        config=conf,
                        argv=['test_plugin_calls_package1', '-v'],
                        exit=False)
        print man.calls()
        assert man.called

        self.assertEqual(man.calls(), [
            'loadPlugins', 'addOptions', 'configure', 'begin',
            'prepareTestLoader', 'loadTestsFromNames', 'loadTestsFromName',
            'prepareTestRunner', 'prepareTest', 'setOutputStream',
            'prepareTestResult', 'beforeDirectory', 'wantFile',
            'wantDirectory', 'beforeContext', 'beforeImport', 'afterImport',
            'wantModule', 'wantClass', 'wantFunction', 'makeTest',
            'wantMethod', 'loadTestsFromTestClass', 'loadTestsFromTestCase',
            'loadTestsFromModule', 'startContext', 'beforeTest',
            'prepareTestCase', 'startTest', 'describeTest', 'testName',
            'addSuccess', 'stopTest', 'afterTest', 'stopContext',
            'afterContext', 'loadTestsFromDir', 'afterDirectory', 'report',
            'finalize'
        ])
Exemplo n.º 15
0
def run_iptest():
    """Run the IPython test suite using nose.

    This function is called when this script is **not** called with the form
    `iptest all`.  It simply calls nose with appropriate command line flags
    and accepts all of the standard nose arguments.
    """
    # Apply our monkeypatch to Xunit
    if '--with-xunit' in sys.argv and not hasattr(Xunit, 'orig_addError'):
        monkeypatch_xunit()

    warnings.filterwarnings(
        'ignore',
        'This will be removed soon.  Use IPython.testing.util instead')

    argv = sys.argv + [
        '--detailed-errors',  # extra info in tracebacks
        '--with-ipdoctest',
        '--ipdoctest-tests',
        '--ipdoctest-extension=txt',

        # We add --exe because of setuptools' imbecility (it
        # blindly does chmod +x on ALL files).  Nose does the
        # right thing and it tries to avoid executables,
        # setuptools unfortunately forces our hand here.  This
        # has been discussed on the distutils list and the
        # setuptools devs refuse to fix this problem!
        '--exe',
    ]
    if '-a' not in argv and '-A' not in argv:
        argv = argv + ['-a', '!crash']

    if nose.__version__ >= '0.11':
        # I don't fully understand why we need this one, but depending on what
        # directory the test suite is run from, if we don't give it, 0 tests
        # get run.  Specifically, if the test suite is run from the source dir
        # with an argument (like 'iptest.py IPython.core', 0 tests are run,
        # even if the same call done in this directory works fine).  It appears
        # that if the requested package is in the current dir, nose bails early
        # by default.  Since it's otherwise harmless, leave it in by default
        # for nose >= 0.11, though unfortunately nose 0.10 doesn't support it.
        argv.append('--traverse-namespace')

    # use our plugin for doctesting.  It will remove the standard doctest plugin
    # if it finds it enabled
    plugins = [IPythonDoctest(make_exclude()), KnownFailure()]

    # We need a global ipython running in this process, but the special
    # in-process group spawns its own IPython kernels, so for *that* group we
    # must avoid also opening the global one (otherwise there's a conflict of
    # singletons).  Ultimately the solution to this problem is to refactor our
    # assumptions about what needs to be a singleton and what doesn't (app
    # objects should, individual shells shouldn't).  But for now, this
    # workaround allows the test suite for the inprocess module to complete.
    if not 'IPython.kernel.inprocess' in sys.argv:
        globalipapp.start_ipython()

    # Now nose can run
    TestProgram(argv=argv, addplugins=plugins)
Exemplo n.º 16
0
    def run(self):
        if TestProgram is None:
            self.error(
                "no nosetests framework found, please install python nose packge first!"
            )
            return

        TestProgram(argv=[self.test_dir], exit=False)
Exemplo n.º 17
0
def main():
    """Invoke Nose's `TestProgram` with extra plugins.

    At the command-line it's still necessary to enable these with the flags
    ``--with-crochet``, ``--with-resources``, ``--with-scenarios``, and so on.
    """
    return TestProgram(addplugins=(
        Crochet(), Resources(), Scenarios(), Select(), SelectBucket(),
        Subunit()))
Exemplo n.º 18
0
def run_iptest():
    """Run the IPython test suite using nose.
    
    This function is called when this script is **not** called with the form
    `iptest all`.  It simply calls nose with appropriate command line flags
    and accepts all of the standard nose arguments.
    """

    warnings.filterwarnings(
        'ignore',
        'This will be removed soon.  Use IPython.testing.util instead')

    argv = sys.argv + [
        # Loading ipdoctest causes problems with Twisted.
        # I am removing this as a temporary fix to get the
        # test suite back into working shape.  Our nose
        # plugin needs to be gone through with a fine
        # toothed comb to find what is causing the problem.
        '--with-ipdoctest',
        '--ipdoctest-tests',
        '--ipdoctest-extension=txt',
        '--detailed-errors',

        # We add --exe because of setuptools' imbecility (it
        # blindly does chmod +x on ALL files).  Nose does the
        # right thing and it tries to avoid executables,
        # setuptools unfortunately forces our hand here.  This
        # has been discussed on the distutils list and the
        # setuptools devs refuse to fix this problem!
        '--exe',
    ]

    # Detect if any tests were required by explicitly calling an IPython
    # submodule or giving a specific path
    has_tests = False
    for arg in sys.argv:
        if 'IPython' in arg or arg.endswith('.py') or \
           (':' in arg and  '.py' in arg):
            has_tests = True
            break

    # If nothing was specifically requested, test full IPython
    if not has_tests:
        argv.append('IPython')

    # Construct list of plugins, omitting the existing doctest plugin, which
    # ours replaces (and extends).
    plugins = [IPythonDoctest(EXCLUDE)]
    for p in nose.plugins.builtin.plugins:
        plug = p()
        if plug.name == 'doctest':
            continue

        #print '*** adding plugin:',plug.name  # dbg
        plugins.append(plug)

    TestProgram(argv=argv, plugins=plugins)
Exemplo n.º 19
0
def run_iptest():
    """Run the IPython test suite using nose.
    
    This function is called when this script is **not** called with the form
    `iptest all`.  It simply calls nose with appropriate command line flags
    and accepts all of the standard nose arguments.
    """

    warnings.filterwarnings(
        'ignore',
        'This will be removed soon.  Use IPython.testing.util instead')

    argv = sys.argv + [
        '--detailed-errors',  # extra info in tracebacks

        # Loading ipdoctest causes problems with Twisted, but
        # our test suite runner now separates things and runs
        # all Twisted tests with trial.
        '--with-ipdoctest',
        '--ipdoctest-tests',
        '--ipdoctest-extension=txt',

        # We add --exe because of setuptools' imbecility (it
        # blindly does chmod +x on ALL files).  Nose does the
        # right thing and it tries to avoid executables,
        # setuptools unfortunately forces our hand here.  This
        # has been discussed on the distutils list and the
        # setuptools devs refuse to fix this problem!
        '--exe',
    ]

    if nose.__version__ >= '0.11':
        # I don't fully understand why we need this one, but depending on what
        # directory the test suite is run from, if we don't give it, 0 tests
        # get run.  Specifically, if the test suite is run from the source dir
        # with an argument (like 'iptest.py IPython.core', 0 tests are run,
        # even if the same call done in this directory works fine).  It appears
        # that if the requested package is in the current dir, nose bails early
        # by default.  Since it's otherwise harmless, leave it in by default
        # for nose >= 0.11, though unfortunately nose 0.10 doesn't support it.
        argv.append('--traverse-namespace')

    # Construct list of plugins, omitting the existing doctest plugin, which
    # ours replaces (and extends).
    plugins = [IPythonDoctest(make_exclude()), KnownFailure()]
    for p in nose.plugins.builtin.plugins:
        plug = p()
        if plug.name == 'doctest':
            continue
        plugins.append(plug)

    # We need a global ipython running in this process
    globalipapp.start_ipython()
    # Now nose can run
    TestProgram(argv=argv, plugins=plugins)
Exemplo n.º 20
0
 def test_namespace_pkg(self):
     """Ensure namespace packages work/can import from each other"""
     stream = StringIO()
     runner = TestRunner(stream=stream)
     runner.verbosity = 2
     prog = TestProgram(argv=[''], testRunner=runner, exit=False)
     res = runner.result
     self.assertEqual(res.testsRun, 1,
                      "Expected to run 1 test, ran %s" % res.testsRun)
     assert res.wasSuccessful()
     assert not res.errors
     assert not res.failures
Exemplo n.º 21
0
    def run(self):
        """ Run bcfg2-test """
        core = self.get_core()
        clients = Bcfg2.Options.setup.clients or core.metadata.clients
        ignore = self.get_ignore()

        if Bcfg2.Options.setup.children:
            if Bcfg2.Options.setup.children > len(clients):
                self.logger.info("Refusing to spawn more children than "
                                 "clients to test, setting children=%s" %
                                 len(clients))
                Bcfg2.Options.setup.children = len(clients)
            perchild = int(
                ceil(len(clients) / float(Bcfg2.Options.setup.children + 1)))
            queue = Queue()
            for child in range(Bcfg2.Options.setup.children):
                start = child * perchild
                end = (child + 1) * perchild
                child = Process(target=self.run_child,
                                args=(clients[start:end], queue))
                child.start()

            def generate_tests():
                """ Read test results for the clients """
                start = Bcfg2.Options.setup.children * perchild
                for client in clients[start:]:
                    yield ClientTest(core, client, ignore)

                for i in range(start):  # pylint: disable=W0612
                    yield ClientTestFromQueue(*queue.get())
        else:

            def generate_tests():
                """ Run tests for the clients """
                for client in clients:
                    yield ClientTest(core, client, ignore)

        result = TestProgram(argv=sys.argv[:1] +
                             Bcfg2.Options.setup.nose_options,
                             suite=LazySuite(generate_tests),
                             exit=False)

        # block until all children have completed -- should be
        # immediate since we've already gotten all the results we
        # expect
        for child in active_children():
            child.join()

        core.shutdown()
        if result.success:
            os._exit(0)  # pylint: disable=W0212
        else:
            os._exit(1)  # pylint: disable=W0212
Exemplo n.º 22
0
 def test_defaultTest_list(self):
     stream = StringIO()
     runner = TestRunner(stream=stream, verbosity=2)
     tests = [os.path.join(support, 'package2'),
              os.path.join(support, 'package3')]
     prog = TestProgram(defaultTest=tests,
                        argv=['test_run_support_package2_3', '-v'],
                        testRunner=runner,
                        config=Config(),
                        exit=False)
     res = runner.result
     print(stream.getvalue())
     self.assertEqual(res.testsRun, 7)
Exemplo n.º 23
0
def test_lessons_solutions(exit=True):
    with TemporaryDirectory() as temp_dir:
        abs_path = os.path.abspath(temp_dir)
        for lesson in iter_code_lessons():
            for solution in iter_lesson_solutions(lesson):
                write_solution_test_file(temp_dir, solution)

        suite = unittest.TestLoader().discover(abs_path)
        program = TestProgram(suite=suite, exit=False)

        if exit:
            sys.exit(int(not program.success))

        return program
Exemplo n.º 24
0
    def test_with_todo_plugin(self):
        pkpath = os.path.join(support, 'todo')
        sys.path.insert(0, pkpath)
        from todoplug import TodoPlugin

        stream = StringIO()
        config = Config(stream=stream,
                        plugins=PluginManager([TodoPlugin()]))
        
        TestProgram(argv=['t', '--with-todo', pkpath],
                    config=config, exit=False)
        out = stream.getvalue()
        print out
        self.assert_('FAILED (TODO=1)' in out)
Exemplo n.º 25
0
    def test_illegal_packages_not_selected(self):
        stream = StringIO()
        runner = TestRunner(stream=stream, verbosity=2)

        prog = TestProgram(defaultTest=os.path.join(support, 'issue143'),
                           argv=['test_issue_143'],
                           testRunner=runner,
                           config=Config(stream=stream,
                                         plugins=DefaultPluginManager()),
                           exit=False)
        res = runner.result
        print stream.getvalue()
        self.assertEqual(res.testsRun, 0)
        assert res.wasSuccessful()
        assert not res.errors
        assert not res.failures
Exemplo n.º 26
0
 def test_traverse_namespace(self):
     """Ensure the --traverse-namespace option tests the other
     namespace package sibling also.
     """
     stream = StringIO()
     runner = TestRunner(stream=stream)
     runner.verbosity = 2
     prog = TestProgram(argv=['', '--traverse-namespace'],
                        testRunner=runner,
                        exit=False)
     res = runner.result
     self.assertEqual(res.testsRun, 2,
                      "Expected to run 2 tests, ran %s" % res.testsRun)
     assert res.wasSuccessful()
     assert not res.errors
     assert not res.failures
Exemplo n.º 27
0
def main():
    # Add the App Engine SDK to the system path.
    sys.path.insert(0, APPENGINE_SDK_PATH)

    # For good measure, also update the PYTHONPATH environment variable.
    os.environ['PYTHONPATH'] = APPENGINE_SDK_PATH

    # Let the dev_appserver do some magic fixing.
    import dev_appserver
    dev_appserver.fix_sys_path()

    # Add the project libraries to the PYTHONPATH.
    import config
    config.configure_libraries()

    # Run just like nosetests.
    return TestProgram()
Exemplo n.º 28
0
        def run(self):
            """ensure tests are capable of being run, then
            run nose.main with a reconstructed argument list"""
            if getattr(self.distribution, 'use_2to3', False):
                # If we run 2to3 we can not do this inplace:

                # Ensure metadata is up-to-date
                build_py = self.get_finalized_command('build_py')
                build_py.inplace = 0
                build_py.run()
                bpy_cmd = self.get_finalized_command("build_py")
                build_path = bpy_cmd.build_lib

                # Build extensions
                egg_info = self.get_finalized_command('egg_info')
                egg_info.egg_base = build_path
                egg_info.run()

                build_ext = self.get_finalized_command('build_ext')
                build_ext.inplace = 0
                build_ext.run()
            else:
                self.run_command('egg_info')

                # Build extensions in-place
                build_ext = self.get_finalized_command('build_ext')
                build_ext.inplace = 1
                build_ext.run()

            if self.distribution.install_requires:
                self.distribution.fetch_build_eggs(
                    self.distribution.install_requires)
            if self.distribution.tests_require:
                self.distribution.fetch_build_eggs(
                    self.distribution.tests_require)

            ei_cmd = self.get_finalized_command("egg_info")
            argv = ['nosetests', '--where', ei_cmd.egg_base]
            for (option_name, cmd_name) in list(self.option_to_cmds.items()):
                if option_name in option_blacklist:
                    continue
                value = getattr(self, option_name)
                if value is not None:
                    argv.extend(
                        self.cfgToArg(option_name.replace('_', '-'), value))
            TestProgram(argv=argv, config=self.__config)
Exemplo n.º 29
0
 def test_run_buggy_generators(self):
     stream = StringIO()
     runner = TestRunner(stream=stream)
     prog = TestProgram(argv=[
         'nosetests',
         os.path.join(support, 'test_buggy_generators.py')
     ],
                        testRunner=runner,
                        config=Config(),
                        exit=False)
     res = runner.result
     print stream.getvalue()
     self.assertEqual(res.testsRun, 12,
                      "Expected to run 12 tests, ran %s" % res.testsRun)
     assert not res.wasSuccessful()
     assert len(res.errors) == 4
     assert not res.failures
Exemplo n.º 30
0
    def test_run_support_package2(self):
        """Collect and run tests in functional_tests/support/package2

        This should collect and run 5 tests.
        """
        stream = StringIO()
        runner = TestRunner(stream=stream)
        prog = TestProgram(defaultTest=os.path.join(support, 'package2'),
                           argv=['test_run_support_package2', '-v'],
                           testRunner=runner,
                           config=Config(),
                           exit=False)
        res = runner.result
        print(stream.getvalue())
        self.assertEqual(res.testsRun, 5,
                         "Expected to run 5 tests, ran %s" % res.testsRun)
        assert res.wasSuccessful()
        assert not res.errors
        assert not res.failures
Exemplo n.º 31
0
def main():
    """Run the IPython test suite.
    """

    warnings.filterwarnings(
        'ignore',
        'This will be removed soon.  Use IPython.testing.util instead')

    # construct list of plugins, omitting the existing doctest plugin
    plugins = [IPythonDoctest()]
    for p in nose.plugins.builtin.plugins:
        plug = p()
        if plug.name == 'doctest':
            continue

        #print 'adding plugin:',plug.name  # dbg
        plugins.append(plug)

    argv = sys.argv + [
        '--doctest-tests',
        '--doctest-extension=txt',
        '--detailed-errors',

        # We add --exe because of setuptools' imbecility (it
        # blindly does chmod +x on ALL files).  Nose does the
        # right thing and it tries to avoid executables,
        # setuptools unfortunately forces our hand here.  This
        # has been discussed on the distutils list and the
        # setuptools devs refuse to fix this problem!
        '--exe',
    ]

    has_ip = False
    for arg in sys.argv:
        if 'IPython' in arg:
            has_ip = True
            break

    if not has_ip:
        argv.append('IPython')

    TestProgram(argv=argv, plugins=plugins)
Exemplo n.º 32
0
from nose.core import TestProgram

t = TestProgram(['blackhole.test'])
t.runTests()