• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python doctests.Doctest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _perform_the_testrun

 def _perform_the_testrun(self, directories, results_queue, previous_report = None):
     try:
         ensure_mpd_is_running()
         
         null_device = open('/dev/null')
         os.stdin = null_device
         report = MakeAReportOfATestRun(previous_report, results_queue)
         doctest = Doctest()
         doctest.enabled = True
         plugins = [doctest, report, Skip(), Capture()] 
         argv = ['nose', '-v']
         old_working_directory = os.getcwd()
         if not self.WORKING_DIRECTORY is None:
             argv.extend(['-w', self.WORKING_DIRECTORY])
             os.chdir(self.WORKING_DIRECTORY)
             
         argv.extend( directories)
         argv.extend(['--with-doctest', '--doctest-extension=txt'])
         
         result = TestProgram(exit = False, argv=argv, plugins=plugins);
         
         os.chdir(old_working_directory)
         results_queue.put(('test-report', report,) )
     except :
         results_queue.put(('test-error', 'Exception happened: ' + str(sys.exc_info()[0]) + " - " + str(sys.exc_info()[1]), ))
     finally:
         results_queue.put(None)
         MPI.Finalize()
开发者ID:Ingwar,项目名称:amuse,代码行数:28,代码来源:background_test.py


示例2: test_collect_no_collect

 def test_collect_no_collect(self):
     # bug http://nose.python-hosting.com/ticket/55
     # we got "iteration over non-sequence" when no files match
     here = os.path.abspath(os.path.dirname(__file__))
     support = os.path.join(here, 'support')
     plug = Doctest()
     for test in plug.loadTestsFromFile(os.path.join(support, 'foo')):
         self.fail("Expected no tests, got %s" % test)
开发者ID:jiffyclub,项目名称:nose,代码行数:8,代码来源:test_plugins.py


示例3: test_add_options

    def test_add_options(self):
        # doctest plugin adds some options...
        conf = Config()
        opt = Bucket()
        parser = MockOptParser()
        plug = Doctest()

        plug.add_options(parser, {})
        o, d = parser.opts[0]
        assert o[0] == '--with-doctest'

        o2, d2 = parser.opts[1]
        assert o2[0] == '--doctest-tests'

        o3, d3 = parser.opts[2]
        assert o3[0] == '--doctest-extension'
开发者ID:jiffyclub,项目名称:nose,代码行数:16,代码来源:test_plugins.py


示例4: test_collect_pymodule

    def test_collect_pymodule(self):
        here = os.path.dirname(__file__)
        support = os.path.join(here, 'support')
        if not support in sys.path:
            sys.path.insert(0, support)
        import foo.bar.buz

        conf = Config()
        opt = Bucket()
        plug = Doctest()
        plug.can_configure = True
        plug.configure(opt, conf)
        suite = plug.loadTestsFromModule(foo.bar.buz)
        expect = ['[afunc (foo.bar.buz)]']
        for test in suite:
            self.assertEqual(str(test), expect.pop(0))
开发者ID:jiffyclub,项目名称:nose,代码行数:16,代码来源:test_plugins.py


示例5: test_config

    def test_config(self):
        # test that configuration works properly when both environment
        # and command line specify a doctest extension
        parser = OptionParser()
        env = {'NOSE_DOCTEST_EXTENSION':'ext'}
        argv = ['--doctest-extension', 'txt']
        dtp = Doctest()
        dtp.add_options(parser, env)
        options, args = parser.parse_args(argv)

        print options
        print args
        self.assertEqual(options.doctestExtension, ['ext', 'txt'])

        env = {}
        parser = OptionParser()
        dtp.add_options(parser, env)
        options, args = parser.parse_args(argv)
        print options
        print args
        self.assertEqual(options.doctestExtension, ['txt'])
开发者ID:jiffyclub,项目名称:nose,代码行数:21,代码来源:test_plugins.py


示例6: test_config

    def test_config(self):
        # test that configuration works properly when both environment
        # and command line specify a doctest extension
        parser = OptionParser()
        env = {"NOSE_DOCTEST_EXTENSION": "ext"}
        argv = ["--doctest-extension", "txt"]
        dtp = Doctest()
        dtp.add_options(parser, env)
        options, args = parser.parse_args(argv)

        print(options)
        print(args)
        self.assertEqual(options.doctestExtension, ["ext", "txt"])

        env = {}
        parser = OptionParser()
        dtp.add_options(parser, env)
        options, args = parser.parse_args(argv)
        print(options)
        print(args)
        self.assertEqual(options.doctestExtension, ["txt"])
开发者ID:GaloisInc,项目名称:echronos,代码行数:21,代码来源:test_plugins.py


示例7: test_matches

 def test_matches(self):
     # doctest plugin wants tests from all NON-test modules
     conf = Config()
     opt = Bucket()
     plug = Doctest()
     plug.can_configure = True
     plug.configure(opt, conf)
     assert not plug.matches('test')
     assert plug.matches('foo')
开发者ID:jiffyclub,项目名称:nose,代码行数:9,代码来源:test_plugins.py


示例8: test_collect_txtfile

    def test_collect_txtfile(self):
        here = os.path.abspath(os.path.dirname(__file__))
        support = os.path.join(here, 'support')
        fn = os.path.join(support, 'foo', 'doctests.txt')

        conf = Config()
        opt = Bucket()
        plug = Doctest()
        plug.can_configure = True
        plug.configure(opt, conf)
        plug.extension = ['.txt']
        suite = plug.loadTestsFromFile(fn)
        for test in suite:
            assert str(test).endswith('doctests.txt')
            assert test.address(), "Test %s has no address"
开发者ID:jiffyclub,项目名称:nose,代码行数:15,代码来源:test_plugins.py


示例9: test_want_file

    def test_want_file(self):
        # doctest plugin can select module and/or non-module files
        conf = Config()
        opt = Bucket()
        plug = Doctest()
        plug.can_configure = True
        plug.configure(opt, conf)

        assert plug.wantFile('foo.py')
        assert not plug.wantFile('bar.txt')
        assert not plug.wantFile('buz.rst')
        assert not plug.wantFile('bing.mov')

        plug.extension = ['.txt', '.rst']
        assert plug.wantFile('/path/to/foo.py')
        assert plug.wantFile('/path/to/bar.txt')
        assert plug.wantFile('/path/to/buz.rst')
        assert not plug.wantFile('/path/to/bing.mov')
开发者ID:jiffyclub,项目名称:nose,代码行数:18,代码来源:test_plugins.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python logcapture.LogCapture类代码示例发布时间:2022-05-27
下一篇:
Python base.Plugin类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap