當前位置: 首頁>>代碼示例>>Python>>正文


Python doctests.Doctest方法代碼示例

本文整理匯總了Python中nose.plugins.doctests.Doctest方法的典型用法代碼示例。如果您正苦於以下問題:Python doctests.Doctest方法的具體用法?Python doctests.Doctest怎麽用?Python doctests.Doctest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nose.plugins.doctests的用法示例。


在下文中一共展示了doctests.Doctest方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: loadTestsFromModule

# 需要導入模塊: from nose.plugins import doctests [as 別名]
# 或者: from nose.plugins.doctests import Doctest [as 別名]
def loadTestsFromModule(self, module):
        if not self.matches(module.__name__):
            npd.log.debug("Doctest doesn't want module %s", module)
            return
        try:
            tests = self.finder.find(module)
        except AttributeError:
            # nose allows module.__test__ = False; doctest does not and
            # throws AttributeError
            return
        if not tests:
            return
        tests.sort()
        module_file = src(module.__file__)
        for test in tests:
            if not test.examples:
                continue
            if not test.filename:
                test.filename = module_file
            # Set test namespace; test altered in place
            self.set_test_context(test)
            yield self.doctest_case_class(test,
                                          optionflags=self.doctest_optflags,
                                          checker=self.out_check_class(),
                                          result_var=self.doctest_result_var)

    # Add an afterContext method to nose.plugins.doctests.Doctest in order
    # to restore print options to the original state after each doctest 
開發者ID:amoose136,項目名稱:radar,代碼行數:30,代碼來源:noseclasses.py

示例2: wantFile

# 需要導入模塊: from nose.plugins import doctests [as 別名]
# 或者: from nose.plugins.doctests import Doctest [as 別名]
def wantFile(self, file):
        bn = os.path.basename(file)
        if bn in self.doctest_ignore:
            return False
        return npd.Doctest.wantFile(self, file) 
開發者ID:amoose136,項目名稱:radar,代碼行數:7,代碼來源:noseclasses.py

示例3: loadTestsFromModule

# 需要導入模塊: from nose.plugins import doctests [as 別名]
# 或者: from nose.plugins.doctests import Doctest [as 別名]
def loadTestsFromModule(self, module):
        #print '*** ipdoctest - lTM',module  # dbg

        if not self.matches(module.__name__):
            log.debug("Doctest doesn't want module %s", module)
            return

        tests = self.finder.find(module,globs=self.globs,
                                 extraglobs=self.extraglobs)
        if not tests:
            return

        # always use whitespace and ellipsis options
        optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS

        tests.sort()
        module_file = module.__file__
        if module_file[-4:] in ('.pyc', '.pyo'):
            module_file = module_file[:-1]
        for test in tests:
            if not test.examples:
                continue
            if not test.filename:
                test.filename = module_file

            yield DocTestCase(test,
                              optionflags=optionflags,
                              checker=self.checker) 
開發者ID:thomasyimgit,項目名稱:leetcode,代碼行數:30,代碼來源:ipdoctest.py

示例4: configure

# 需要導入模塊: from nose.plugins import doctests [as 別名]
# 或者: from nose.plugins.doctests import Doctest [as 別名]
def configure(self, options, config):
        # it is overriden in order to fix doctest options discovery

        Plugin.configure(self, options, config)
        self.doctest_result_var = options.doctest_result_var
        self.doctest_tests = options.doctest_tests
        self.extension = tolist(options.doctestExtension)
        self.fixtures = options.doctestFixtures
        self.finder = doctest.DocTestFinder()

        #super(DoctestPluginHelper, self).configure(options, config)
        self.optionflags = 0
        self.options = {}

        if options.doctestOptions:
            stroptions = ",".join(options.doctestOptions).split(',')
            for stroption in stroptions:
                try:
                    if stroption.startswith('+'):
                        self.optionflags |= doctest.OPTIONFLAGS_BY_NAME[stroption[1:]]
                        continue
                    elif stroption.startswith('-'):
                        self.optionflags &= ~doctest.OPTIONFLAGS_BY_NAME[stroption[1:]]
                        continue
                    try:
                        key,value=stroption.split('=')
                    except ValueError:
                        pass
                    else:
                        if not key in self.OPTION_BY_NAME:
                            raise ValueError()
                        self.options[key]=value
                        continue
                except (AttributeError, ValueError, KeyError):
                    raise ValueError("Unknown doctest option {}".format(stroption))
                else:
                    raise ValueError("Doctest option is not a flag or a key/value pair: {} ".format(stroption)) 
開發者ID:Thejas-1,項目名稱:Price-Comparator,代碼行數:39,代碼來源:doctest_nose_plugin.py

示例5: loadPlugins

# 需要導入模塊: from nose.plugins import doctests [as 別名]
# 或者: from nose.plugins.doctests import Doctest [as 別名]
def loadPlugins(self):
            for plug in builtin.plugins:
                if plug != Doctest:
                    self.addPlugin(plug())
            self.addPlugin(DoctestFix())
            super(NltkPluginManager, self).loadPlugins() 
開發者ID:Thejas-1,項目名稱:Price-Comparator,代碼行數:8,代碼來源:runtests.py

示例6: loadPlugins

# 需要導入模塊: from nose.plugins import doctests [as 別名]
# 或者: from nose.plugins.doctests import Doctest [as 別名]
def loadPlugins(self):
            for plug in builtin.plugins:
                if plug != Doctest:
                    self.addPlugin(plug())
            self.addPlugin(DoctestFix())
            if rednose_available:
                self.addPlugin(RedNose())

            super(NltkPluginManager, self).loadPlugins() 
開發者ID:sdoran35,項目名稱:hate-to-hugs,代碼行數:11,代碼來源:runtests.py


注:本文中的nose.plugins.doctests.Doctest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。