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


Python util.TestApp类代码示例

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


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


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