Beispiel #1
0
    def test_command_line_options_enable(self):
        parser = OptionParser()

        p = debug.Pdb()
        p.addOptions(parser)
        options, args = parser.parse_args(
            ['test_configuration', '--pdb', '--pdb-failures'])
        p.configure(options, Config())
        assert p.enabled
        assert p.enabled_for_errors
        assert p.enabled_for_failures
Beispiel #2
0
    def test_disabled_by_default(self):
        p = debug.Pdb()
        assert not p.enabled
        assert not p.enabled_for_failures

        parser = OptionParser()
        p.addOptions(parser)
        options, args = parser.parse_args(['test_configuration'])
        p.configure(options, Config())
        assert not p.enabled
        assert not p.enabled_for_errors
        assert not p.enabled_for_failures
Beispiel #3
0
    def test_env_settings_enable(self):
        p = debug.Pdb()
        assert not p.enabled
        assert not p.enabled_for_failures

        env = {'NOSE_PDB': '1', 'NOSE_PDB_FAILURES': '1'}

        parser = OptionParser()
        p.addOptions(parser, env)
        options, args = parser.parse_args(['test_configuration'])
        p.configure(options, Config())
        assert p.enabled
        assert p.enabled_for_errors
        assert p.enabled_for_failures
Beispiel #4
0
    def test_plugin_calls_pdb(self):
        p = debug.Pdb()

        try:
            raise Exception("oops")
        except:
            err = sys.exc_info()

        p.enabled = True
        p.enabled_for_errors = True
        p.enabled_for_failures = True

        p.addError(None, err)
        assert debug.pdb.called, "Did not call pdb.post_mortem on error"

        debug.pdb.called = False
        p.addFailure(None, err)
        assert debug.pdb.called, "Did not call pdb.post_mortem on failure"
Beispiel #5
0
    def test_skip_prevents_pdb_call(self):
        class TC(unittest.TestCase):
            def test(self):
                raise SkipTest('not me')

        skip = Skip()
        skip.enabled = True
        p = debug.Pdb()
        p.enabled = True
        p.enabled_for_errors = True
        res = unittest.TestResult()
        conf = Config(plugins=PluginManager(plugins=[skip, p]))
        rpf = ResultProxyFactory(conf)
        test = case.Test(TC('test'), resultProxy=rpf)
        test(res)

        assert not res.errors, "Skip was recorded as error %s" % res.errors
        assert not debug.pdb.called, "pdb was called"
Beispiel #6
0
    def test_real_stdout_restored_before_call(self):
        class CheckStdout(StubPdb):
            def post_mortem(self, tb):
                assert sys.stdout is sys.__stdout__, \
                    "sys.stdout was not restored to sys.__stdout__ " \
                    "before call"

        debug.pdb = CheckStdout()

        patch = StringIO()
        sys.stdout = patch
        p = debug.Pdb()
        p.enabled = True
        p.enabled_for_errors = True

        try:
            raise Exception("oops")
        except:
            err = sys.exc_info()

        p.addError(None, err)
        assert sys.stdout is patch, "sys.stdout was not reset after call"
Beispiel #7
0
 def test_plugin_api(self):
     p = debug.Pdb()
     p.addOptions
     p.configure
     p.addError
     p.addFailure
Beispiel #8
0
    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()

    all_suites = ['quick', 'push', 'full']
    suite_vars = [suite + "suite" for suite in all_suites]
    testproblem_group = optparse.OptionGroup(parser,
                                             "Test problem selection options")
    testproblem_group.add_option(
        "",
        "--suite",
        dest="test_suite",
        default=unknown,
        help=
        "quick: 37 tests in ~15 minutes, push: 48 tests in ~60 minutes, full: 96 tests in ~60 hours.",
        choices=all_suites,
        metavar=all_suites)