Exemplo n.º 1
0
def test_blacklist_specificity(parse_style, target_package, blacklist, tmpdir):
    """ Available, non-blacklisted entities should be used/included. """
    contents = exec_test(tmpdir.strpath,
                         target_package,
                         parse_style,
                         blacklist=blacklist)
    goods = set(CLASS_NAMES) - set(blacklist)
    missing = [n for n in goods if n not in contents]
    assert [] == missing, \
        "{} missing doc target(s):\n{}".format(len(missing), "\n".join(missing))
Exemplo n.º 2
0
def test_blacklist_sensitivity(parse_style, target_package, blacklist, tmpdir):
    """ Any blacklisted entity should be excluded. """
    contents = exec_test(tmpdir.strpath,
                         target_package,
                         parse_style,
                         blacklist=blacklist)
    bads = set(blacklist)
    present = [n for n in bads if n in contents]
    assert [] == present, \
        "{} unexpected doc target(s):\n{}".format(len(present), "\n".join(present))
Exemplo n.º 3
0
def test_whitelist_specificity(parse_style, target_package, whitelist, tmpdir):
    """ Non whitelisted entities should be excluded. """
    contents = exec_test(tmpdir.strpath,
                         target_package,
                         parse_style,
                         whitelist=whitelist)
    bads = set(CLASS_NAMES) - set(whitelist)
    present = [n for n in bads if n in contents]
    assert [] == present, \
        "{} unexpected doc target(s):\n{}".format(len(present), "\n".join(present))
Exemplo n.º 4
0
def test_export_specificifty(tmpdir, target_package, parse_style, exports,
                             modlines):
    """ When exports are declared, only those members are documented. """
    try_cat_module(os.path.join(tmpdir.strpath, target_package))
    print("tmpdir contents: {}".format(os.listdir(tmpdir.strpath)))
    print("package: {}".format(target_package))
    print("package contents: {}".format(
        os.listdir(os.path.join(tmpdir.strpath, target_package))))
    contents = exec_test(tmpdir.strpath, target_package, parse_style)
    present = [n for n in set(CLASS_NAMES) - set(exports) if n in contents]
    assert [] == present, \
        "{} unexpected doc target(s):\n{}".format(len(present), "\n".join(present))
Exemplo n.º 5
0
def test_export_sensitivity(tmpdir, target_package, parse_style, exports,
                            modlines):
    """ Each exported member is documented. """
    try_cat_module(os.path.join(tmpdir.strpath, target_package))
    print("tmpdir contents: {}".format(os.listdir(tmpdir.strpath)))
    print("package: {}".format(target_package))
    print("package contents: {}".format(
        os.listdir(os.path.join(tmpdir.strpath, target_package))))
    contents = exec_test(tmpdir.strpath, target_package, parse_style)
    missing = [n for n in exports if n not in contents]
    assert [] == missing, \
        "Missing {} doc target(s):\n{}".format(len(missing), "\n".join(missing))
Exemplo n.º 6
0
def test_protection_sensitivity(tmpdir, target_package, parse_style, protected,
                                modlines):
    """ Protected members are not documented. """
    output = exec_test(tmpdir.strpath, target_package, parse_style)
    exp_absent_names = {
        n
        for k in protected
        for n in [DATA[k]] + [DATA[ksub] for ksub in NESTING.get(k, [])]
    }
    present = {n for n in exp_absent_names if n in output or "_" + n in output}
    assert set() == present, "{} unexpected doc target(s):\n{}".\
        format(len(present), "\n".join(present))
Exemplo n.º 7
0
def test_whitelist_sensitivity(parse_style, target_package, whitelist, tmpdir):
    """ Any available whitelisted entity should be used/included. """
    contents = exec_test(tmpdir.strpath,
                         target_package,
                         parse_style,
                         whitelist=whitelist)
    missing = [n for n in set(whitelist) if n not in contents]
    # DEBUG
    print("Files in package folder:\n" +
          "\n".join(os.listdir(os.path.join(tmpdir.strpath, target_package))))
    print("Outfile contents:\n" + contents)
    assert [] == missing, \
        "Missing {} doc target(s):\n{}".format(len(missing), "\n".join(missing))
Exemplo n.º 8
0
def test_protection_specificity(tmpdir, target_package, parse_style, protected,
                                modlines):
    """ Unprotected members are documented. """
    output = exec_test(tmpdir.strpath, target_package, parse_style)
    prot_keys = set(protected) | \
                set(itertools.chain(*[NESTING.get(k, []) for k in protected]))
    exp_present_names = {v for k, v in DATA.items() if k not in prot_keys}
    missing = {n for n in exp_present_names if n not in output}
    mods = [
        os.path.join(tmpdir.strpath, target_package, f)
        for f in os.listdir(os.path.join(tmpdir.strpath, target_package))
        if f != "__init__.py" and f.endswith(".py")
    ]
    assert 1 == len(mods)
    with open(mods[0], 'r') as f:
        print("Conents of file {}:\n".format(mods[0]) + f.read())
    assert set() == missing, \
        "Missing {} doc target(s):\n{}".format(len(missing), "\n".join(missing))