diff options
author | Jarrod Millman <jarrod.millman@gmail.com> | 2022-05-10 14:41:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-10 14:41:21 -0700 |
commit | 171e353a8c84c04754208cc7abfe20210a093692 (patch) | |
tree | 7406d44c4f64d6299526bb3348ad02307ccf572a /numpydoc/tests/test_full.py | |
parent | 9233a8284ec9512f3655d47790949deac316ab6b (diff) | |
parent | 4b38c01e680cf2032acb09819bc0985e5dfc5ca8 (diff) | |
download | numpydoc-171e353a8c84c04754208cc7abfe20210a093692.tar.gz |
Merge pull request #391 from jarrodmillman/black
Use black
Diffstat (limited to 'numpydoc/tests/test_full.py')
-rw-r--r-- | numpydoc/tests/test_full.py | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/numpydoc/tests/test_full.py b/numpydoc/tests/test_full.py index 16e60e5..e0defe2 100644 --- a/numpydoc/tests/test_full.py +++ b/numpydoc/tests/test_full.py @@ -9,27 +9,28 @@ from sphinx.util.docutils import docutils_namespace # Test framework adapted from sphinx-gallery (BSD 3-clause) -@pytest.fixture(scope='module') +@pytest.fixture(scope="module") def sphinx_app(tmpdir_factory): - temp_dir = (tmpdir_factory.getbasetemp() / 'root').strpath - src_dir = op.join(op.dirname(__file__), 'tinybuild') + temp_dir = (tmpdir_factory.getbasetemp() / "root").strpath + src_dir = op.join(op.dirname(__file__), "tinybuild") def ignore(src, names): - return ('_build', 'generated') + return ("_build", "generated") shutil.copytree(src_dir, temp_dir, ignore=ignore) # For testing iteration, you can get similar behavior just doing `make` # inside the tinybuild directory src_dir = temp_dir conf_dir = temp_dir - out_dir = op.join(temp_dir, '_build', 'html') - toctrees_dir = op.join(temp_dir, '_build', 'toctrees') - kwargs = {'warningiserror': True, 'keep_going': True} + out_dir = op.join(temp_dir, "_build", "html") + toctrees_dir = op.join(temp_dir, "_build", "toctrees") + kwargs = {"warningiserror": True, "keep_going": True} # Avoid warnings about re-registration, see: # https://github.com/sphinx-doc/sphinx/issues/5038 with docutils_namespace(): - app = Sphinx(src_dir, conf_dir, out_dir, toctrees_dir, - buildername='html', **kwargs) + app = Sphinx( + src_dir, conf_dir, out_dir, toctrees_dir, buildername="html", **kwargs + ) # need to build within the context manager # for automodule and backrefs to work app.build(False, []) @@ -39,46 +40,48 @@ def sphinx_app(tmpdir_factory): def test_MyClass(sphinx_app): """Test that class documentation is reasonable.""" src_dir, out_dir = sphinx_app.srcdir, sphinx_app.outdir - class_rst = op.join(src_dir, 'generated', - 'numpydoc_test_module.MyClass.rst') + class_rst = op.join(src_dir, "generated", "numpydoc_test_module.MyClass.rst") with open(class_rst) as fid: rst = fid.read() - assert r'numpydoc\_test\_module' in rst # properly escaped - class_html = op.join(out_dir, 'generated', - 'numpydoc_test_module.MyClass.html') + assert r"numpydoc\_test\_module" in rst # properly escaped + class_html = op.join(out_dir, "generated", "numpydoc_test_module.MyClass.html") with open(class_html) as fid: html = fid.read() # ensure that no autodoc weirdness ($) occurs - assert '$self' not in html - assert '/,' not in html - assert '__init__' in html # inherited + assert "$self" not in html + assert "/," not in html + assert "__init__" in html # inherited # escaped * chars should no longer be preceded by \'s, # if we see a \* in the output we know it's incorrect: - assert r'\*' not in html + assert r"\*" not in html # "self" should not be in the parameter list for the class: - assert 'self,' not in html + assert "self," not in html # check xref was embedded properly (dict should link using xref): - assert 'stdtypes.html#dict' in html + assert "stdtypes.html#dict" in html def test_my_function(sphinx_app): """Test that function documentation is reasonable.""" out_dir = sphinx_app.outdir - function_html = op.join(out_dir, 'generated', - 'numpydoc_test_module.my_function.html') + function_html = op.join( + out_dir, "generated", "numpydoc_test_module.my_function.html" + ) with open(function_html) as fid: html = fid.read() - assert r'\*args' not in html - assert '*args' in html + assert r"\*args" not in html + assert "*args" in html # check xref (iterable should link using xref): - assert 'glossary.html#term-iterable' in html + assert "glossary.html#term-iterable" in html -@pytest.mark.parametrize(("html_file", "expected_length"), ( - (["index.html"], 1), - (["generated", "numpydoc_test_module.my_function.html"], 1), - (["generated", "numpydoc_test_module.MyClass.html"], 1), -)) +@pytest.mark.parametrize( + ("html_file", "expected_length"), + ( + (["index.html"], 1), + (["generated", "numpydoc_test_module.my_function.html"], 1), + (["generated", "numpydoc_test_module.MyClass.html"], 1), + ), +) def test_reference(sphinx_app, html_file, expected_length): """Test for bad references""" out_dir = sphinx_app.outdir @@ -90,4 +93,4 @@ def test_reference(sphinx_app, html_file, expected_length): assert len(reference_list) == expected_length for ref in reference_list: - assert '-' not in ref # Bad reference if it contains "-" e.g. R1896e33633d5-1 + assert "-" not in ref # Bad reference if it contains "-" e.g. R1896e33633d5-1 |