コード例 #1
0
ファイル: nbtest.py プロジェクト: jss367/fastai-pythonic
def build_tests_markdown(elt):
    fn_name = nbdoc.fn_name(elt)
    md = ""
    db_matches = [get_links(t) for t in lookup_db(elt)]
    md += tests2md(db_matches, "")
    try:
        related = [get_links(t) for t in find_related_tests(elt)]
        other_tests = [
            k for k in OrderedDict.fromkeys(related) if k not in db_matches
        ]
        md += tests2md(other_tests,
                       f"Some other tests where `{fn_name}` is used:")
    except OSError as e:
        pass

    if len(md.strip()) == 0:
        return (
            f"No tests found for `{fn_name}`."
            " To contribute a test please refer to [this guide](/dev/test.html)"
            " and [this discussion](https://forums.fast.ai/t/improving-expanding-functional-tests/32929)."
        )
    return (
        f"Tests found for `{fn_name}`: {md}"
        "\n\nTo run tests please refer to this [guide](/dev/test.html#quick-guide)."
    )
コード例 #2
0
ファイル: nbtest.py プロジェクト: zhhhzhang/fastai
def show_test(elt, search=True, markdown: bool = True) -> str:
    "Show associated tests for a fastai function/class"
    fn_name = nbdoc.fn_name(elt)
    md = ''

    db_matches = [get_links(t) for t in lookup_db(elt)]
    md += tests2markdown(ifnone(db_matches, []), 'This tests')

    if search:
        try:
            direct, related = find_tests(elt)
            direct = [get_links(t) for t in direct]
            related = [get_links(t) for t in related]
            direct = list(set(direct) - set(db_matches))
            related = list(set(related) - set(db_matches) - set(direct))
            md += tests2markdown(direct, 'Direct tests')
            md += tests2markdown(related, 'Related tests')
        except OSError as e:
            print(
                'Could not find fastai/tests folder. If you installed from conda, please install developer build instead.'
            )

    if len(md) == 0: md = f'No tests found for `{fn_name}`'
    else: md = f'Tests found for `{fn_name}`:' + md

    if markdown: display(Markdown(md))
    else: return md
コード例 #3
0
ファイル: nbtest.py プロジェクト: tufac2/fastai
def build_tests_markdown(elt):
    db_matches = [get_links(t) for t in lookup_db(elt)]
    try:
        direct, related = find_dir_tests(elt)
        direct = [get_links(t) for t in direct]
        related = [get_links(t) for t in related]
        direct = list(set(direct) - set(db_matches))
        related = list(set(related) - set(db_matches) - set(direct))
    except OSError as e:
        #print('Could not find fastai/tests folder. If you installed from conda, please install developer build instead.')
        direct, related = [], []

    md = ''.join([
        tests2md(db_matches, ''),
        tests2md(direct, 'Direct tests:'),
        tests2md(related, 'Related tests:')
    ])
    fn_name = nbdoc.fn_name(elt)
    if len(md) == 0:
        return (
            f'No tests found for `{fn_name}`.'
            ' To contribute a test please refer to [this guide](/dev/test.html)'
            ' and [this discussion](https://forums.fast.ai/t/improving-expanding-functional-tests/32929).'
        )
    return (
        f'Tests found for `{fn_name}`: {md}'
        '\n\nTo run tests please refer to this [guide](/dev/test.html#quick-guide).'
    )
コード例 #4
0
ファイル: nbtest.py プロジェクト: tejten/fastai
def build_tests_markdown(elt):
    db_matches = [get_links(t) for t in lookup_db(elt)]
    try:
        direct, related = find_dir_tests(elt)
        other_tests = [get_links(t) for t in (related + direct)]
        other_tests = [
            k for k in OrderedDict.fromkeys(other_tests) if k not in db_matches
        ]
    except OSError as e:
        #print('Could not find fastai/tests folder. If you installed from conda, please install developer build instead.')
        other_tests = []

    fn_name = nbdoc.fn_name(elt)
    md = ''.join([
        tests2md(db_matches, ''),
        tests2md(other_tests, f'Some other tests where `{fn_name}` is used:')
    ])
    if len(md) == 0:
        return (
            f'No tests found for `{fn_name}`.'
            ' To contribute a test please refer to [this guide](/dev/test.html)'
            ' and [this discussion](https://forums.fast.ai/t/improving-expanding-functional-tests/32929).'
        )
    return (
        f'Tests found for `{fn_name}`: {md}'
        '\n\nTo run tests please refer to this [guide](/dev/test.html#quick-guide).'
    )
コード例 #5
0
ファイル: nbtest.py プロジェクト: SiddharthTiwari/fastai
def build_tests_markdown(elt):
    fn_name = nbdoc.fn_name(elt)
    md = ''
    db_matches = [get_links(t) for t in lookup_db(elt)]
    md += tests2md(db_matches, '')
    try:
        related = [get_links(t) for t in find_related_tests(elt)]
        other_tests = [k for k in OrderedDict.fromkeys(related) if k not in db_matches]
        md += tests2md(other_tests, f'Some other tests where `{fn_name}` is used:')
    except OSError as e: pass

    if len(md.strip())==0:
        return (f'No tests found for `{fn_name}`.'
                ' To contribute a test please refer to [this guide](/dev/test.html)'
                ' and [this discussion](https://forums.fast.ai/t/improving-expanding-functional-tests/32929).')
    return (f'Tests found for `{fn_name}`: {md}'
            '\n\nTo run tests please refer to this [guide](/dev/test.html#quick-guide).')
コード例 #6
0
def build_tests_markdown(elt):
    db_matches = [get_links(t) for t in lookup_db(elt)]
    try:
        direct, related = find_dir_tests(elt)
        direct = [get_links(t) for t in direct]
        related = [get_links(t) for t in related]
        direct = list(set(direct) - set(db_matches))
        related = list(set(related) - set(db_matches) - set(direct))
    except OSError as e:
        #print('Could not find fastai/tests folder. If you installed from conda, please install developer build instead.')
        direct, related = [], []

    md = ''.join([
        tests2md(db_matches, 'This tests'),
        tests2md(direct, 'Direct tests'),
        tests2md(related, 'Related tests')
    ])
    fn_name = nbdoc.fn_name(elt)
    if len(md) == 0: return f'No tests found for `{fn_name}`', md
    else: return f'Tests found for `{fn_name}`:', md