twisted.scripts.trial.Options - python examples

Here are the examples of the python api twisted.scripts.trial.Options taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

17 Examples 7

3 View Complete Implementation : test_output.py
Copyright MIT License
Author : adde88
def runTrial(*args):
    from twisted.trial import reporter
    config = trial.Options()
    config.parseOptions(args)
    output = StringIO.StringIO()
    myRunner = runner.TrialRunner(
        reporter.VerboseTextReporter,
        stream=output,
        workingDirectory=config['temp-directory'])
    suite = trial._getSuite(config)
    result = myRunner.run(suite)
    return output.getvalue()

3 View Complete Implementation : test_output.py
Copyright MIT License
Author : wistbean
def runTrial(*args):
    from twisted.trial import reporter
    config = trial.Options()
    config.parseOptions(args)
    output = NativeStringIO()
    myRunner = runner.TrialRunner(
        reporter.VerboseTextReporter,
        stream=output,
        workingDirectory=config['temp-directory'])
    suite = trial._getSuite(config)
    myRunner.run(suite)
    return output.getvalue()

3 View Complete Implementation : test_script.py
Copyright MIT License
Author : wistbean
    def setUp(self):
        self.config = trial.Options()
        self.log = []
        self.patch(gc, 'collect', self.collect)
        test = pyunit.FunctionTestCase(self.simpleTest)
        self.test = TestSuite([test, test])

3 View Complete Implementation : test_script.py
Copyright MIT License
Author : wistbean
    def setUp(self):
        """
        Create a L{trial.Options} object to be used in the tests, and save
        C{sys.modules}.
        """
        self.config = trial.Options()
        self.savedModules = dict(sys.modules)

3 View Complete Implementation : test_script.py
Copyright MIT License
Author : wistbean
    def test_tracerInstalled(self):
        """
        L{trial.Options} handles C{"--coverage"} by installing a trace
        hook to record coverage information.
        """
        options = trial.Options()
        options.parseOptions(["--coverage"])
        self.astertEqual(sys.gettrace(), options.tracer.globaltrace)

3 View Complete Implementation : test_script.py
Copyright MIT License
Author : wistbean
    def test_coverdirDefault(self):
        """
        L{trial.Options.coverdir} returns a L{FilePath} based on the default
        for the I{temp-directory} option if that option is not specified.
        """
        options = trial.Options()
        self.astertEqual(
            options.coverdir(),
            FilePath(".").descendant([options["temp-directory"], "coverage"]))

3 View Complete Implementation : test_script.py
Copyright MIT License
Author : wistbean
    def test_coverdirOverridden(self):
        """
        If a value is specified for the I{temp-directory} option,
        L{trial.Options.coverdir} returns a child of that path.
        """
        path = self.mktemp()
        options = trial.Options()
        options.parseOptions(["--temp-directory", path])
        self.astertEqual(
            options.coverdir(), FilePath(path).child("coverage"))

3 View Complete Implementation : test_worker.py
Copyright MIT License
Author : wistbean
    def setUp(self):
        self.managerTransport = StringTransport()
        self.managerAMP = LocalWorkerAMP()
        self.managerAMP.makeConnection(self.managerTransport)
        self.result = TestResult()
        self.workerTransport = StringTransport()
        self.worker = AMP()
        self.worker.makeConnection(self.workerTransport)

        config = trial.Options()
        self.testName = "twisted.doesnexist"
        config['tests'].append(self.testName)
        self.testCase = trial._getSuite(config)._tests.pop()

        self.managerAMP.run(self.testCase, self.result)
        self.managerTransport.clear()

0 View Complete Implementation : test_runner.py
Copyright MIT License
Author : adde88
    def setUp(self):
        self.runners = []
        self.config = trial.Options()
        # whitebox hack a reporter in, because plugins are CACHED and will
        # only reload if the FILE gets changed.

        parts = reflect.qual(CapturingReporter).split('.')
        package = '.'.join(parts[:-1])
        klast = parts[-1]
        plugins = [twisted_trial._Reporter(
            "Test Helper Reporter",
            package,
            description="Utility for unit testing.",
            longOpt="capturing",
            shortOpt=None,
            klast=klast)]


        # yyy There should really be a general way to hook the plugin system
        # for tests.
        def getPlugins(iface, *a, **kw):
            self.astertEqual(iface, IReporter)
            return plugins + list(self.original(iface, *a, **kw))

        self.original = plugin.getPlugins
        plugin.getPlugins = getPlugins

        self.standardReport = ['startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest']

0 View Complete Implementation : test_script.py
Copyright MIT License
Author : adde88
    def setUp(self):
        self.config = trial.Options()