mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #7163 from tk0miya/fix_DeprecationWarning
Fix DeprecationWarnings on testing
This commit is contained in:
@@ -25,15 +25,16 @@ def test_dirhtml(app, status, warning):
|
||||
assert (app.outdir / 'foo/foo_2/index.html').exists()
|
||||
assert (app.outdir / 'bar/index.html').exists()
|
||||
|
||||
content = (app.outdir / 'index.html').text()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
assert 'href="foo/"' in content
|
||||
assert 'href="foo/foo_1/"' in content
|
||||
assert 'href="foo/foo_2/"' in content
|
||||
assert 'href="bar/"' in content
|
||||
|
||||
# objects.inv (refs: #7095)
|
||||
f = (app.outdir / 'objects.inv').open('rb')
|
||||
invdata = InventoryFile.load(f, 'path/to', posixpath.join)
|
||||
with (app.outdir / 'objects.inv').open('rb') as f:
|
||||
invdata = InventoryFile.load(f, 'path/to', posixpath.join)
|
||||
|
||||
assert 'index' in invdata.get('std:doc')
|
||||
assert ('Python', '', 'path/to/', '-') == invdata['std:doc']['index']
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ def test_domain_py_objects(app, status, warning):
|
||||
def test_resolve_xref_for_properties(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'module.html').text()
|
||||
content = (app.outdir / 'module.html').read_text()
|
||||
assert ('Link to <a class="reference internal" href="#module_a.submodule.ModTopLevel.prop"'
|
||||
' title="module_a.submodule.ModTopLevel.prop">'
|
||||
'<code class="xref py py-attr docutils literal notranslate"><span class="pre">'
|
||||
|
||||
@@ -40,7 +40,7 @@ class ComplainOnUnhighlighted(PygmentsBridge):
|
||||
|
||||
|
||||
def test_add_lexer(app, status, warning):
|
||||
app.add_lexer('test', MyLexer())
|
||||
app.add_lexer('test', MyLexer)
|
||||
|
||||
bridge = PygmentsBridge('html')
|
||||
ret = bridge.highlight_block('ab', 'test')
|
||||
|
||||
@@ -18,7 +18,7 @@ import sphinx
|
||||
from sphinx.errors import ExtensionError, PycodeError
|
||||
from sphinx.testing.util import strip_escseq
|
||||
from sphinx.util import (
|
||||
SkipProgressMessage, display_chunk, encode_uri, ensuredir, get_module_source,
|
||||
SkipProgressMessage, display_chunk, encode_uri, ensuredir,
|
||||
import_object, parselinenos, progress_message, status_iterator, xmlname_checker
|
||||
)
|
||||
from sphinx.util import logging
|
||||
@@ -61,16 +61,6 @@ def test_display_chunk():
|
||||
assert display_chunk(('hello', 'sphinx', 'world')) == 'hello .. world'
|
||||
|
||||
|
||||
def test_get_module_source():
|
||||
assert get_module_source('sphinx') == ('file', sphinx.__file__)
|
||||
|
||||
# failed to obtain source information from builtin modules
|
||||
with pytest.raises(PycodeError):
|
||||
get_module_source('builtins')
|
||||
with pytest.raises(PycodeError):
|
||||
get_module_source('itertools')
|
||||
|
||||
|
||||
def test_import_object():
|
||||
module = import_object('sphinx')
|
||||
assert module.__name__ == 'sphinx'
|
||||
|
||||
@@ -20,76 +20,6 @@ from sphinx.util import inspect
|
||||
from sphinx.util.inspect import stringify_signature
|
||||
|
||||
|
||||
def test_getargspec():
|
||||
def func(a, b, c=1, d=2, *e, **f):
|
||||
pass
|
||||
|
||||
spec = inspect.getargspec(func)
|
||||
assert spec.args == ['a', 'b', 'c', 'd']
|
||||
assert spec.varargs == 'e'
|
||||
assert spec.varkw == 'f'
|
||||
assert spec.defaults == (1, 2)
|
||||
assert spec.kwonlyargs == []
|
||||
assert spec.kwonlydefaults is None
|
||||
assert spec.annotations == {}
|
||||
|
||||
|
||||
def test_getargspec_partial():
|
||||
def func1(a, b, c=1, d=2, *e, **f):
|
||||
pass
|
||||
|
||||
partial = functools.partial(func1, 10, c=11)
|
||||
spec = inspect.getargspec(partial)
|
||||
assert spec.args == ['b']
|
||||
assert spec.varargs is None
|
||||
assert spec.varkw == 'f'
|
||||
assert spec.defaults is None
|
||||
assert spec.kwonlyargs == ['c', 'd']
|
||||
assert spec.kwonlydefaults == {'c': 11, 'd': 2}
|
||||
assert spec.annotations == {}
|
||||
|
||||
|
||||
def test_getargspec_partial2():
|
||||
def fun(a, b, c=1, d=2):
|
||||
pass
|
||||
p = functools.partial(fun, 10, c=11)
|
||||
|
||||
def f_expected(b, *, c=11, d=2):
|
||||
pass
|
||||
expected = inspect.getargspec(f_expected)
|
||||
|
||||
assert expected == inspect.getargspec(p)
|
||||
|
||||
|
||||
def test_getargspec_builtin_type():
|
||||
with pytest.raises(TypeError):
|
||||
inspect.getargspec(int)
|
||||
|
||||
|
||||
def test_getargspec_bound_methods():
|
||||
def f_expected_unbound(self, arg1, **kwargs):
|
||||
pass
|
||||
expected_unbound = inspect.getargspec(f_expected_unbound)
|
||||
|
||||
def f_expected_bound(arg1, **kwargs):
|
||||
pass
|
||||
expected_bound = inspect.getargspec(f_expected_bound)
|
||||
|
||||
class Foo:
|
||||
def method(self, arg1, **kwargs):
|
||||
pass
|
||||
|
||||
bound_method = Foo().method
|
||||
|
||||
@functools.wraps(bound_method)
|
||||
def wrapped_bound_method(*args, **kwargs):
|
||||
pass
|
||||
|
||||
assert expected_unbound == inspect.getargspec(Foo.method)
|
||||
assert expected_bound == inspect.getargspec(bound_method)
|
||||
assert expected_bound == inspect.getargspec(wrapped_bound_method)
|
||||
|
||||
|
||||
def test_signature():
|
||||
# literals
|
||||
with pytest.raises(TypeError):
|
||||
|
||||
Reference in New Issue
Block a user