mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove testscases for getargspec() (deprecated)
This commit is contained in:
parent
0e2e31a612
commit
7e79822355
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user