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


Python Config.configure方法代码示例

本文整理汇总了Python中nose.config.Config.configure方法的典型用法代码示例。如果您正苦于以下问题:Python Config.configure方法的具体用法?Python Config.configure怎么用?Python Config.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nose.config.Config的用法示例。


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

示例1: collector

# 需要导入模块: from nose.config import Config [as 别名]
# 或者: from nose.config.Config import configure [as 别名]
def collector():
    """TestSuite replacement entry point. Use anywhere you might use a
    unittest.TestSuite. The collector will, by default, load options from
    all config files and execute loader.loadTestsFromNames() on the
    configured testNames, or '.' if no testNames are configured.
    """    
    # plugins that implement any of these methods are disabled, since
    # we don't control the test runner and won't be able to run them
    # finalize() is also not called, but plugins that use it aren't disabled,
    # because capture needs it.
    setuptools_incompat = ('report', 'prepareTest',
                           'prepareTestLoader', 'prepareTestRunner',
                           'setOutputStream')

    plugins = RestrictedPluginManager(exclude=setuptools_incompat)
    conf = Config(files=all_config_files(),
                  plugins=plugins)
    conf.configure(argv=['collector'])
    loader = defaultTestLoader(conf)

    if conf.testNames:
        suite = loader.loadTestsFromNames(conf.testNames)
    else:
        suite = loader.loadTestsFromNames(('.',))
    return FinalizingSuiteWrapper(suite, plugins.finalize)
开发者ID:antlong,项目名称:nose,代码行数:27,代码来源:core.py

示例2: TestIdTest

# 需要导入模块: from nose.config import Config [as 别名]
# 或者: from nose.config.Config import configure [as 别名]
class TestIdTest(unittest.TestCase):
    tests_location = "tests/data/testid/testid.py"
    idfile_location = "data/testid/.noseids"

    def setUp(self):
        self.idfile = os.path.abspath(
            os.path.join(os.path.dirname(__file__), self.idfile_location))
        parser = optparse.OptionParser()
        argv = [
            # 0 is always program
            "lode_runner",
            "--failed",
            "--with-id",
            "--id-file=%s" % self.idfile
        ]
        self.x = TestId()
        self.x.add_options(parser, env={})
        (options, args) = parser.parse_args(argv)
        self.config = Config()
        self.x.configure(options, self.config)
        self.config.plugins = PluginManager()
        self.config.plugins.addPlugin(Dataprovider())
        self.config.plugins.addPlugin(TestId())
        self.config.configure(argv)

    def tearDown(self):
        try:
            os.remove(self.idfile)
        except OSError:
            pass

    def test_load_tests_path_with_no_info_in_idfile(self):
        names = self.x.loadTestsFromNames([self.tests_location])
        self.assertEqual((None, [self.tests_location]), names)

    def test_loaded_names_with_failing_tests_in_idfile(self):
        stream = StringIO()

        tests = TestLoader(config=self.config).loadTestsFromName(self.tests_location)
        result = LodeTestResult(stream, None, 0)
        tests.run(result)
        # generate needed idfile
        self.config.plugins.finalize(result)

        names = self.x.loadTestsFromNames([self.tests_location])
        loaded_tests = [(parse_test_name(name)[1], parse_test_name(name)[2]) for name in names[1]]
        self.assertEqual(
            [('DataprovidedTestCase','test_with_dataprovider_failing_on_everything_except_2_1'),
             ('DataprovidedTestCase','test_with_dataprovider_failing_on_everything_except_2_3')], loaded_tests)
开发者ID:z00sts,项目名称:lode_runner,代码行数:51,代码来源:test_testid.py

示例3: DiscoverTest

# 需要导入模块: from nose.config import Config [as 别名]
# 或者: from nose.config.Config import configure [as 别名]
class DiscoverTest(unittest.TestCase):
    tests_location = "tests/data/dataprovided/dataprovided.py"
    tested_test = ":TestCase.test_with_dataprovider_fixture_2"
    argv = []

    ran_1_test = "Ran 1 test"
    no_such_test = "ValueError: No such test"

    def setUp(self):
        self.config = Config()
        self.config.plugins = PluginManager()
        self.config.plugins.addPlugin(Dataprovider())
        self.config.configure(self.argv)

    def tearDown(self):
        del sys.modules["dataprovided"]
        self.argv = []
开发者ID:sh0ked,项目名称:lode_runner,代码行数:19,代码来源:test_discover_dataprovided_test.py

示例4: test_config_file_set_by_arg

# 需要导入模块: from nose.config import Config [as 别名]
# 或者: from nose.config.Config import configure [as 别名]
 def test_config_file_set_by_arg(self):
     c = Config()
     c.configure(['test_config_file_set_by_arg',
                  '-c', self.cfg_file, '-v'])
     # 10 from file, 1 more from cmd line
     self.assertEqual(c.verbosity, 11)
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:8,代码来源:test_config_files.py

示例5: test_load_config_file

# 需要导入模块: from nose.config import Config [as 别名]
# 或者: from nose.config.Config import configure [as 别名]
 def test_load_config_file(self):
     c = Config(files=self.cfg_file)
     c.configure(['test_load_config_file'])
     self.assertEqual(c.verbosity, 10)
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:6,代码来源:test_config_files.py


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