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

Python util.TestApp类代码示例

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

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



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

示例1: test_build

def test_build():
    for buildername in ('pickle', 'json', 'linkcheck', 'text', 'htmlhelp',
                        'qthelp', 'epub', 'changes', 'singlehtml', 'xml',
                        'pseudoxml'):
        app = TestApp(buildername=buildername)
        yield lambda app: app.builder.build_all(), app
        app.cleanup()
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:7,代码来源:test_build.py


示例2: setup_module

def setup_module():
    global app
    app = TestApp()
    app.builder.env.app = app
    app.builder.env.temp_data["docname"] = "dummy"
    app.connect("autodoc-process-docstring", process_docstring)
    app.connect("autodoc-process-signature", process_signature)
    app.connect("autodoc-skip-member", skip_member)
开发者ID:4grim,项目名称:hackbright-django,代码行数:8,代码来源:test_autodoc.py


示例3: setup_module

def setup_module():
    global app, original, original_uids
    app = TestApp(testroot="versioning")
    app.builder.env.app = app
    app.connect("doctree-resolved", on_doctree_resolved)
    app.build()
    original = doctrees["original"]
    original_uids = [n.uid for n in add_uids(original, is_paragraph)]
开发者ID:Lyoness,项目名称:sphinx,代码行数:8,代码来源:test_versioning.py


示例4: test_extensions

def test_extensions():
    status, warnings = StringIO(), StringIO()
    app = TestApp(status=status, warning=warnings)
    try:
        app.setup_extension('shutil')
        assert warnings.getvalue().startswith("WARNING: extension 'shutil'")
    finally:
        app.cleanup()
开发者ID:ChimmyTee,项目名称:oh-mainline,代码行数:8,代码来源:test_application.py


示例5: setup_module

def setup_module():
    global app, original, original_uids
    app = TestApp()
    app.builder.env.app = app
    app.connect('doctree-resolved', on_doctree_resolved)
    app.build()
    original = doctrees['versioning/original']
    original_uids = [n.uid for n in add_uids(original, is_paragraph)]
开发者ID:zsiddiqui2,项目名称:sphinxGit,代码行数:8,代码来源:test_versioning.py


示例6: verify_build

def verify_build(buildername, srcdir):
    if buildername == 'man' and ManWriter is None:
        raise SkipTest('man writer is not available')
    app = TestApp(buildername=buildername, srcdir=srcdir)
    try:
        app.builder.build_all()
    finally:
        app.cleanup()
开发者ID:wubw,项目名称:sphinx,代码行数:8,代码来源:test_build.py


示例7: test_correct_year

def test_correct_year():
    try:
        # save current value of SOURCE_DATE_EPOCH
        sde = os.environ.pop('SOURCE_DATE_EPOCH',None)

        # test with SOURCE_DATE_EPOCH unset: no modification
        app = TestApp(buildername='html',testroot='correct-year')
        app.builder.build_all()
        content = (app.outdir / 'contents.html').text()
        app.cleanup()
        assert '2006-2009' in content

        # test with SOURCE_DATE_EPOCH set: copyright year should be
        # updated
        os.environ['SOURCE_DATE_EPOCH'] = "1293840000"
        app = TestApp(buildername='html',testroot='correct-year')
        app.builder.build_all()
        content = (app.outdir / 'contents.html').text()
        app.cleanup()
        assert '2006-2011' in content

        os.environ['SOURCE_DATE_EPOCH'] = "1293839999"
        app = TestApp(buildername='html',testroot='correct-year')
        app.builder.build_all()
        content = (app.outdir / 'contents.html').text()
        app.cleanup()
        assert '2006-2010' in content

    finally:
        # Restores SOURCE_DATE_EPOCH
        if sde == None:
            os.environ.pop('SOURCE_DATE_EPOCH',None)
        else:
            os.environ['SOURCE_DATE_EPOCH'] = sde
开发者ID:BlackYoup,项目名称:sphinx,代码行数:34,代码来源:test_correct_year.py


示例8: deco

 def deco(*args2, **kwargs2):
     app = TestApp(*args, **default_kw)
     (app.srcdir / 'docutils.conf').write_text(docutilsconf)
     try:
         cwd = os.getcwd()
         os.chdir(app.srcdir)
         func(app, *args2, **kwargs2)
     finally:
         os.chdir(cwd)
     # don't execute cleanup if test failed
     app.cleanup()
开发者ID:zsiddiqui2,项目名称:sphinxGit,代码行数:11,代码来源:test_docutilsconf.py


示例9: test_feed

def test_feed():
    app = TestApp(buildername='html', warning=feed_warnfile, cleanenv=True)  
    app.build(force_all=True, filenames=[]) #build_all misses the crucial finish signal
    feed_warnings = feed_warnfile.getvalue().replace(os.sep, '/')
    feed_warnings_exp = FEED_WARNINGS % {'root': app.srcdir}
    yield assert_equals, feed_warnings, feed_warnings_exp
    rss_path = os.path.join(app.outdir, 'rss.xml')
    yield exists, rss_path
    
    base_path = unicode("file:/" + app.outdir)
    
    # see http://www.feedparser.org/
    f = feedparser.parse(rss_path)
    yield assert_equals, f.bozo, 0 #feedparser well-formedness detection. We want this.
    entries = f.entries
    yield assert_equals, entries[0].updated_parsed[0:6], (2001, 8, 11, 13, 0, 0)
    yield assert_equals, entries[0].title, "The latest blog post"
    
    yield assert_equals, entries[0].link, base_path + '/B_latest.html'
    yield assert_equals, entries[0].guid, base_path + '/B_latest.html'
    yield assert_equals, entries[1].updated_parsed[0:6], (2001, 8, 11, 9, 0, 0)
    yield assert_equals, entries[1].title, "An older blog post"
    yield assert_equals, entries[1].link, base_path + '/A_older.html'
    yield assert_equals, entries[1].guid, base_path + '/A_older.html'
    yield assert_equals, entries[2].updated_parsed[0:6], (1979, 1, 1, 0, 0, 0,)
    yield assert_equals, entries[2].title, "The oldest blog post"
    yield assert_equals, entries[2].link, base_path + '/C_most_aged.html'
    yield assert_equals, entries[2].guid, base_path + '/C_most_aged.html'
    #Now we do it all again to make sure that things work when handling stale files
    app2 = TestApp(buildername='html', warning=feed_warnfile)  
    app2.build(force_all=False, filenames=['most_aged'])
    f = feedparser.parse(rss_path)
    yield assert_equals, f.bozo, 0 #feedparser well-formedness detection. We want this.
    entries = f.entries
    yield assert_equals, entries[0].updated_parsed[0:6], (2001, 8, 11, 13, 0, 0)
    yield assert_equals, entries[0].title, "The latest blog post"
    yield assert_equals, entries[1].updated_parsed[0:6], (2001, 8, 11, 9, 0, 0)
    yield assert_equals, entries[1].title, "An older blog post"
    yield assert_equals, entries[2].updated_parsed[0:6], (1979, 1, 1, 0, 0, 0)
    yield assert_equals, entries[2].title, "The oldest blog post"
    
    #Tests for relative URIs. note that these tests only work because there is
    # no xml:base - otherwise feedparser will supposedly fix them up for us - 
    # http://www.feedparser.org/docs/resolving-relative-links.html
    links = BeautifulSoup(entries[0].description).findAll('a')
    # These links will look like:
    #[<a class="headerlink" href="#the-latest-blog-post" title="Permalink to this headline">¶</a>, <a class="reference internal" href="older.html"><em>a relative link</em></a>, <a class="reference external" href="http://google.com/">an absolute link</a>]
    yield assert_equals, links.pop()['href'], "http://google.com/"
    yield assert_equals, links.pop()['href'], base_path + '/A_older.html'
    yield assert_equals, links.pop()['href'], entries[0].link + '#the-latest-blog-post'
    
    app.cleanup()
    app2.cleanup()
开发者ID:whardier,项目名称:sphinx-feed,代码行数:53,代码来源:test_build.py


示例10: test_master_doc_not_found

def test_master_doc_not_found(tmpdir):
    (tmpdir / 'conf.py').write_text('master_doc = "index"')
    assert tmpdir.listdir() == ['conf.py']

    try:
        app = TestApp(buildername='dummy', srcdir=tmpdir)
        app.builder.build_all()
        assert False  # SphinxError not raised
    except Exception as exc:
        assert isinstance(exc, SphinxError)
    finally:
        app.cleanup()
开发者ID:Felix-neko,项目名称:sphinx,代码行数:12,代码来源:test_build.py


示例11: test_nonascii_path

def test_nonascii_path():
    (test_root / '_build').rmtree(True) #keep this to build first gettext

    builder_names = ['gettext', 'html', 'dirhtml', 'singlehtml', 'latex',
                     'texinfo', 'pickle', 'json', 'linkcheck', 'text',
                     'htmlhelp', 'qthelp', 'epub', 'changes', 'xml',
                     'pseudoxml']
    if ManWriter is not None:
        builder_names.append('man')

    for buildername in builder_names:
        app = TestApp(buildername=buildername, srcdir='(temp)')
        yield _test_nonascii_path, app
        app.cleanup()
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:14,代码来源:test_build.py


示例12: deco

        def deco(*args2, **kwargs2):
            # Now, modify the python path...
            srcdir = default_kw['srcdir']
            sys.path.insert(0, srcdir)
            try:
                app = TestApp(*args, **default_kw)
                func(app, *args2, **kwargs2)
            finally:
                if srcdir in sys.path:
                    sys.path.remove(srcdir)
                # remove the auto-generated dummy_module.rst
                dummy_rst = srcdir / 'dummy_module.rst'
                if dummy_rst.isfile():
                    dummy_rst.unlink()

            # don't execute cleanup if test failed
            app.cleanup()
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:17,代码来源:test_autosummary.py


示例13: test_gen_check_types

def test_gen_check_types():
    for key, value, should, deftype in TYPECHECK_OVERRIDES:
        warning = StringIO()
        app = TestApp(confoverrides={key: value}, warning=warning)
        app.cleanup()

        real = type(value).__name__
        msg = ("WARNING: the config value %r has type `%s',"
               " defaults to `%s.'\n" % (key, real, deftype.__name__))
        def test():
            warning_list = warning.getvalue()
            assert (msg in warning_list) == should, \
                    "Setting %s to %r should%s raise: %s" % \
                    (key, value, " not" if should else "", msg)
        test.description = "test_check_type_%s_on_%s" % \
                (real, type(Config.config_values[key][0]).__name__)

        yield test
开发者ID:redvox,项目名称:sphinx,代码行数:18,代码来源:test_config.py


示例14: test_domain_override

def test_domain_override():
    class A(Domain):
        name = 'foo'
    class B(A):
        name = 'foo'
    class C(Domain):
        name = 'foo'
    status, warnings = StringIO(), StringIO()
    app = TestApp(status=status, warning=warnings)
    try:
        # No domain know named foo.
        raises_msg(ExtensionError, 'domain foo not yet registered',
                   app.override_domain, A)
        assert app.add_domain(A) is None
        assert app.override_domain(B) is None
        raises_msg(ExtensionError, 'new domain not a subclass of registered '
                   'foo domain', app.override_domain, C)
    finally:
        app.cleanup()
开发者ID:ChimmyTee,项目名称:oh-mainline,代码行数:19,代码来源:test_application.py


示例15: test_output

def test_output():
    status, warnings = StringIO(), StringIO()
    app = TestApp(status=status, warning=warnings)
    try:
        status.truncate(0) # __init__ writes to status
        status.seek(0)
        app.info("Nothing here...")
        assert status.getvalue() == "Nothing here...\n"
        status.truncate(0)
        status.seek(0)
        app.info("Nothing here...", True)
        assert status.getvalue() == "Nothing here..."

        old_count = app._warncount
        app.warn("Bad news!")
        assert warnings.getvalue() == "WARNING: Bad news!\n"
        assert app._warncount == old_count + 1
    finally:
        app.cleanup()
开发者ID:ChimmyTee,项目名称:oh-mainline,代码行数:19,代码来源:test_application.py


示例16: test_needs_sphinx

def test_needs_sphinx():
    # micro version
    app = TestApp(confoverrides={'needs_sphinx': '1.3.3'})  # OK: less
    app.cleanup()
    app = TestApp(confoverrides={'needs_sphinx': '1.3.4'})  # OK: equals
    app.cleanup()
    raises(VersionRequirementError, TestApp,
           confoverrides={'needs_sphinx': '1.3.5'})  # NG: greater

    # minor version
    app = TestApp(confoverrides={'needs_sphinx': '1.2'})  # OK: less
    app.cleanup()
    app = TestApp(confoverrides={'needs_sphinx': '1.3'})  # OK: equals
    app.cleanup()
    raises(VersionRequirementError, TestApp,
           confoverrides={'needs_sphinx': '1.4'})  # NG: greater

    # major version
    app = TestApp(confoverrides={'needs_sphinx': '0'})  # OK: less
    app.cleanup()
    app = TestApp(confoverrides={'needs_sphinx': '1'})  # OK: equals
    app.cleanup()
    raises(VersionRequirementError, TestApp,
           confoverrides={'needs_sphinx': '2'})  # NG: greater
开发者ID:Basis,项目名称:sphinx,代码行数:24,代码来源:test_config.py


示例17: test_feed_by_parsing_it

 def test_feed_by_parsing_it(self):
     feed_warnfile = self.feed_warnfile
     app = TestApp(buildername='html', warning=feed_warnfile, cleanenv=True)  
     app.build(force_all=True, filenames=[]) #build_all misses the crucial finish signal
     feed_warnings = feed_warnfile.getvalue().replace(os.sep, '/')
     feed_warnings_exp = self.FEED_WARNINGS % {'root': app.srcdir}
     self.assertEqual(feed_warnings, feed_warnings_exp)
     rss_path = os.path.join(app.outdir, 'rss.xml')
     self.assertTrue(exists(rss_path))
 
     base_path = unicode("file:/" + app.outdir)
 
     # see http://www.feedparser.org/
     f = feedparser.parse(rss_path)
     #feedparser well-formedness detection. We want this.
     self.assertEqual(f.bozo, 0 )
     self.assertEqual(f.feed['title'], 'Sphinx Syndicate Test Title')
     entries = f.entries
     self.assertEqual(entries[0].updated_parsed[0:6], (2001, 8, 11, 13, 0, 0))
     self.assertEqual(entries[0].title, "The latest blog post")
 
     self.assertEqual(entries[0].link, base_path + '/B_latest.html')
     self.assertEqual(entries[0].guid, base_path + '/B_latest.html')
     self.assertEqual(entries[1].updated_parsed[0:6], (2001, 8, 11, 9, 0, 0))
     self.assertEqual(entries[1].title, "An older blog post")
     self.assertEqual(entries[1].link, base_path + '/A_older.html')
     self.assertEqual(entries[1].guid, base_path + '/A_older.html')
     self.assertEqual(entries[2].updated_parsed[0:6], (1979, 1, 1, 0, 0, 0,))
     self.assertEqual(entries[2].title, "The oldest blog post")
     self.assertEqual(entries[2].link, base_path + '/C_most_aged.html')
     self.assertEqual(entries[2].guid, base_path + '/C_most_aged.html')
     #Now we do it all again to make sure that things work when handling stale files
     app2 = TestApp(buildername='html', warning=feed_warnfile)  
     app2.build(force_all=False, filenames=['most_aged'])
     f = feedparser.parse(rss_path)
     self.assertEqual(f.bozo, 0)
     entries = f.entries
     self.assertEqual(entries[0].updated_parsed[0:6], (2001, 8, 11, 13, 0, 0))
     self.assertEqual(entries[0].title, "The latest blog post")
     self.assertEqual(entries[1].updated_parsed[0:6], (2001, 8, 11, 9, 0, 0))
     self.assertEqual(entries[1].title, "An older blog post")
     self.assertEqual(entries[2].updated_parsed[0:6], (1979, 1, 1, 0, 0, 0))
     self.assertEqual(entries[2].title, "The oldest blog post")
 
     #Tests for relative URIs. note that these tests only work because there is
     # no xml:base - otherwise feedparser will supposedly fix them up for us - 
     # http://www.feedparser.org/docs/resolving-relative-links.html
     links = BeautifulSoup(entries[0].description).findAll('a')
     # These links will look like:
     #[<a class="headerlink" href="#the-latest-blog-post" title="Permalink to this headline">¶</a>, <a class="reference internal" href="older.html"><em>a relative link</em></a>, <a class="reference external" href="http://google.com/">an absolute link</a>]
     self.assertEqual(links.pop()['href'], "http://google.com/")
     self.assertEqual(links.pop()['href'], base_path + '/A_older.html')
     self.assertEqual(links.pop()['href'], entries[0].link + '#the-latest-blog-post')
 
     index_path  = os.path.join(app.outdir, 'index.html')
     soup = BeautifulSoup(open(index_path).read())
     latest_tree = soup.find('div', 'latest-wrapper')
     latest_items = latest_tree.findAll('li')
     actual_links = [entry.contents[0]['href'] for entry in latest_items]
     ideal_links = [
         u'B_latest.html',
         u'A_older.html',
         u'C_most_aged.html',
     ]
     
     self.assertListEqual(actual_links, ideal_links)
     
     app.cleanup()
     app2.cleanup()
开发者ID:abeaumont,项目名称:sphinx-extensions,代码行数:69,代码来源:test_feed.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.Timer类代码示例发布时间:2022-05-26
下一篇:
Python util.Stack类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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