当前位置: 首页>>代码示例>>Python>>正文


Python trial._getSuite函数代码示例

本文整理汇总了Python中twisted.scripts.trial._getSuite函数的典型用法代码示例。如果您正苦于以下问题:Python _getSuite函数的具体用法?Python _getSuite怎么用?Python _getSuite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_getSuite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: call_trial

def call_trial(*tests):
    import spyne.test
    from glob import glob
    from itertools import chain

    global _ctr
    _ctr += 1
    file_name = 'test_result.%d.subunit' % _ctr
    with SubUnitTee(file_name):
        tests_dir = os.path.dirname(spyne.test.__file__)
        sys.argv = ['trial', '--reporter=subunit']
        sys.argv.extend(chain(*[glob(join(tests_dir, test)) for test in tests]))

        from twisted.scripts.trial import Options
        from twisted.scripts.trial import _makeRunner
        from twisted.scripts.trial import _getSuite

        config = Options()
        config.parseOptions()

        trialRunner = _makeRunner(config)
        suite = _getSuite(config)
        test_result = trialRunner.run(suite)

    try:
        subunit2junitxml(_ctr)
    except Exception as e:
        # this is not super important.
        print e

    return int(not test_result.wasSuccessful())
开发者ID:timic,项目名称:spyne,代码行数:31,代码来源:setup.py

示例2: test_testmoduleOnModule

 def test_testmoduleOnModule(self):
     """
     Check that --testmodule loads a suite which contains the tests
     referred to in test-case-name inside its parameter.
     """
     self.config.opt_testmodule(sibpath('moduletest.py'))
     self.assertSuitesEqual(trial._getSuite(self.config),
                            ['twisted.trial.test.test_test_visitor'])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:8,代码来源:test_script.py

示例3: test_testmoduleOnSelfModule

 def test_testmoduleOnSelfModule(self):
     """
     When given a module that refers to *itself* in the test-case-name
     variable, check that --testmodule only adds the tests once.
     """
     self.config.opt_testmodule(sibpath('moduleself.py'))
     self.assertSuitesEqual(trial._getSuite(self.config),
                            ['twisted.trial.test.moduleself'])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:8,代码来源:test_script.py

示例4: test_testmoduleOnScript

 def test_testmoduleOnScript(self):
     """
     Check that --testmodule loads tests referred to in test-case-name
     buffer variables.
     """
     self.config.opt_testmodule(sibpath('scripttest.py'))
     self.assertSuitesEqual(trial._getSuite(self.config),
                            ['twisted.trial.test.test_test_visitor',
                             'twisted.trial.test.test_class'])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:9,代码来源:test_script.py

示例5: test_testmoduleTwice

 def test_testmoduleTwice(self):
     """
     When the same module is specified with two --testmodule flags, it
     should only appear once in the suite.
     """
     self.config.opt_testmodule(sibpath('moduletest.py'))
     self.config.opt_testmodule(sibpath('moduletest.py'))
     self.assertSuitesEqual(trial._getSuite(self.config),
                            ['twisted.trial.test.test_test_visitor'])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:9,代码来源:test_script.py

示例6: run

    def run():
        config = Options()
        config.parseOptions()

        trialRunner = _makeRunner(config)
        suite = _getSuite(config)
        test_result = trialRunner.run(suite)

        return int(not test_result.wasSuccessful())
开发者ID:KetothXupack,项目名称:spyne,代码行数:9,代码来源:setup.py

示例7: test_testmoduleOnSourceAndTarget

 def test_testmoduleOnSourceAndTarget(self):
     """
     If --testmodule is specified twice, once for module A and once for
     a module which refers to module A, then make sure module A is only
     added once.
     """
     self.config.opt_testmodule(sibpath('moduletest.py'))
     self.config.opt_testmodule(sibpath('test_test_visitor.py'))
     self.assertSuitesEqual(trial._getSuite(self.config),
                            ['twisted.trial.test.test_test_visitor'])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:10,代码来源:test_script.py

示例8: setUp

    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()
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:16,代码来源:test_worker.py

示例9: _tests_func

    def _tests_func(self, tests, worker_index):
        if not isinstance(tests, (list, set)):
            tests = [tests]

        args = ['-e']
        args.extend(tests)

        config = Options()
        config.parseOptions(args)

        stream = BufferWritesDevice()
        runner = self._make_runner(config=config, stream=stream)
        suite = _getSuite(config)
        result = setup_test_db(worker_index, None, runner.run, suite)
        result = TestResult().from_trial_result(result)
        return result
开发者ID:MapStory,项目名称:geonode,代码行数:16,代码来源:runner.py

示例10: test_basic_test

    def test_basic_test(self):
        pkgname='fakepackage4'
        modname='fakemodule4'
        modcontents='\n\
def foofunc():\n\
    x=1\n\
    y=x\n\
'
        testcontents='\n\
from twisted.trial import unittest\n\
from %s import %s\n\
class T(unittest.TestCase):\n\
    def test_thing(self):\n\
        %s.foofunc()\n\
' % (pkgname, modname, modname)

        mockstdout = Mock()
        realstdout=sys.stdout
        sys.stdout = mockstdout
        mockstderr = Mock()
        realstderr=sys.stderr
        sys.stderr = mockstderr
        something = None
        try:
            fileutil.make_dirs(pkgname)
            fileutil.write_file(os.path.join(pkgname, '__init__.py'), '')
            fileutil.write_file(os.path.join(pkgname, modname+'.py'), modcontents)
            fileutil.make_dirs(os.path.join(pkgname, 'test'))
            fileutil.write_file(os.path.join(pkgname, 'test', '__init__.py'), '')
            fileutil.write_file(os.path.join(pkgname, 'test', 'test_'+modname+'.py'), testcontents)
            sys.path.append(os.getcwd())
            trialcoverage.init_paths()
            trialcoverage.start_coverage()

            config = trial.Options()
            config.parseOptions(['--reporter', 'bwverbose-coverage', '%s.test' % pkgname])
            trial._initialDebugSetup(config)
            trialRunner = trial._makeRunner(config)
            suite = trial._getSuite(config)
            something = trialRunner.run(suite)

        finally:
            sys.stdout = realstdout
            sys.stderr = realstderr
            if sys.modules.has_key(pkgname):
                del sys.modules[pkgname]
            fileutil.rm_dir(pkgname)
开发者ID:sanyaade,项目名称:trialcoverage,代码行数:47,代码来源:test_tests.py

示例11: test_preserveArgumentOrder

    def test_preserveArgumentOrder(self):
        """
        Multiple tests passed on the command line are not reordered.
        """
        tests = [
            "twisted.trial.test.test_tests",
            "twisted.trial.test.test_assertions",
            "twisted.trial.test.test_deferreds",
            ]
        self.config.parseOptions(tests)

        suite = trial._getSuite(self.config)
        names = testNames(suite)

        expectedSuite = TestSuite(map(self.loader.loadByName, tests))
        expectedNames = testNames(expectedSuite)

        self.assertEqual(names, expectedNames)
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:18,代码来源:test_script.py

示例12: run_tests

    def run_tests(self):
        # We do the import from Twisted inside the function instead of the top
        # of the file because since Twisted is a setup_requires, we can't
        # assume that Twisted will be installed on the user's system prior, so
        # if we don't do the import here, then importing from this plugin will
        # fail.
        from twisted.scripts import trial

        if not self.testmodule:
            self.testmodule = "bridgedb.test"

        # Handle parsing the trial options passed through the setuptools
        # trial command.
        cmd_options = []
        for opt in self.boolean_options:
            if getattr(self, opt.replace('-', '_'), None):
                cmd_options.append('--%s' % opt)

        for opt in ('debugger', 'jobs', 'random', 'reactor', 'reporter',
                    'testmodule', 'tbformat', 'without-module'):
            value = getattr(self, opt.replace('-', '_'), None)
            if value is not None:
                cmd_options.extend(['--%s' % opt, value])

        config = trial.Options()
        config.parseOptions(cmd_options)
        config['tests'] = [self.testmodule,]

        trial._initialDebugSetup(config)
        trialRunner = trial._makeRunner(config)
        suite = trial._getSuite(config)

        # run the tests
        if self.until_failure:
            test_result = trialRunner.runUntilFailure(suite)
        else:
            test_result = trialRunner.run(suite)

        if test_result.wasSuccessful():
            return 0  # success
        return 1      # failure
开发者ID:liudonghua123,项目名称:bridgedb,代码行数:41,代码来源:setup.py

示例13: len

            r = datastore.Redis.instance()
            r.flushdb()
    else:
        from nova.tests.real_flags import *

    if len(argv) == 1 and len(config['tests']) == 0:
        # If no tests were specified run the ones imported in this file
        # NOTE(termie): "tests" is not a flag, just some Trial related stuff
        config['tests'].update(['__main__'])
    elif len(config['tests']):
        # If we specified tests check first whether they are in __main__
        for arg in config['tests']:
            key = arg.split('.')[0]
            if hasattr(__main__, key):
                config['tests'].remove(arg)
                config['tests'].add('__main__.%s' % arg)

    trial_script._initialDebugSetup(config)
    trialRunner = trial_script._makeRunner(config)
    suite = trial_script._getSuite(config)
    if config['until-failure']:
        test_result = trialRunner.runUntilFailure(suite)
    else:
        test_result = trialRunner.run(suite)
    if config.tracer:
        sys.settrace(None)
        results = config.tracer.results()
        results.write_results(show_missing=1, summary=False,
                              coverdir=config.coverdir)
    sys.exit(not test_result.wasSuccessful())
开发者ID:sorenh,项目名称:cc,代码行数:30,代码来源:run_tests.py

示例14: run_tests

    def run_tests(self):
        global all_modules
        all_modules = self.distribution.get_command_obj(
            'build_py').find_all_modules()

        # We do the import from Twisted inside the function instead of the top
        # of the file because since Twisted is a setup_requires, we can't
        # assume that Twisted will be installed on the user's system prior
        # to using Tahoe, so if we don't do the import here, then importing
        # from this plugin will fail.
        from twisted.scripts import trial

        # Handle parsing the trial options passed through the setuptools
        # trial command.
        cmd_options = []
        if self.reactor is not None:
            cmd_options.extend(['--reactor', self.reactor])
        else:
            # Cygwin requires the poll reactor to work at all.  Linux
            # requires the poll reactor  to avoid twisted bug #3218.
            # In general, the poll reactor is better than the select reactor,
            # but it is not available on all platforms.  According to
            # exarkun on IRC, it is available but buggy on some versions of
            # Mac OS X, so just because you can install it doesn't mean we
            # want to use it on every platform.
            # Unfortunately this leads to this error with some
            # combinations of tools:
            # twisted.python.usage.UsageError: The specified reactor cannot be
            # used, failed with error: reactor already installed.
            if sys.platform in ("cygwin"):
                cmd_options.extend(['--reactor', 'poll'])
        if self.reporter is not None:
            cmd_options.extend(['--reporter', self.reporter])
        if self.rterrors is not None:
            cmd_options.append('--rterrors')
        if self.debug_stacktraces is not None:
            cmd_options.append('--debug-stacktraces')
        config = trial.Options()
        config.parseOptions(cmd_options)

        args = self.test_args
        if type(args) == str:
            args = [args, ]

        config['tests'] = args

        if self.coverage:
            config.opt_coverage()

        trial._initialDebugSetup(config)
        trialRunner = trial._makeRunner(config)
        suite = trial._getSuite(config)

        # run the tests
        if self.until_failure:
            test_result = trialRunner.runUntilFailure(suite)
        else:
            test_result = trialRunner.run(suite)

        # write coverage data
        if config.tracer:
            sys.settrace(None)
            results = config.tracer.results()
            results.write_results(show_missing=1, summary=False,
                                  coverdir=config.coverdir)

        if test_result.wasSuccessful():
            sys.exit(0)  # success
        else:
            sys.exit(1)  # failure
开发者ID:rutsky,项目名称:setuptools-trial,代码行数:70,代码来源:setuptools_trial.py

示例15: main

def main():
    always_succeed = '--always-succeed' in sys.argv
    if always_succeed:
        sys.argv.remove('--always-succeed')

    # Copypasta from twisted.scripts.trial.run, to tweak the return values
    if len(sys.argv) == 1:
        sys.argv.append("--help")
    config = trial.Options()
    try:
        config.parseOptions()
    except usage.error, ue:
        raise SystemExit, "%s: %s" % (sys.argv[0], ue)
    trial._initialDebugSetup(config)
    trialRunner = trial._makeRunner(config)
    suite = trial._getSuite(config)
    if config['until-failure']:
        test_result = trialRunner.runUntilFailure(suite)
    else:
        test_result = trialRunner.run(suite)
    if config.tracer:
        sys.settrace(None)
        results = config.tracer.results()
        results.write_results(show_missing=1, summary=False,
                              coverdir=config.coverdir)
    # Copypasta ends here
    if always_succeed or test_result.wasSuccessful():
        return 0
    else:
        return 2
开发者ID:pombredanne,项目名称:testutils,代码行数:30,代码来源:trial.py


注:本文中的twisted.scripts.trial._getSuite函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。