當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。