Commit 75175aee authored by Stefan Behnel's avatar Stefan Behnel

add signature tests for new function duck-typing in Py3.4

--HG--
extra : amend_source : 1bdb5f011d5234a8631b04ac0e5f9df9fe6a4de0
extra : transplant_source : %A1Z%B1%2C%CE%B4%D6%20SMS%CA%12%7D%2B%1A%FC%00%E1%CD
parent 98d60492
......@@ -4,6 +4,56 @@
import sys
IS_PY3 = sys.version_info[0] >= 3
IS_PY34 = sys.version_info > (3, 4, 0, 'beta', 3)
def inspect_isroutine():
"""
>>> inspect_isroutine()
True
"""
import inspect
return inspect.isroutine(inspect_isroutine)
def inspect_isfunction():
"""
>>> inspect_isfunction()
False
False
"""
import inspect, types
print isinstance(inspect_isfunction, types.FunctionType)
return inspect.isfunction(inspect_isfunction)
def inspect_isbuiltin():
"""
>>> inspect_isbuiltin()
False
False
"""
import inspect, types
print isinstance(inspect_isfunction, types.BuiltinFunctionType)
return inspect.isbuiltin(inspect_isbuiltin)
def inspect_signature(a, b, c=123, *, d=234):
"""
>>> sig = inspect_signature(1, 2)
>>> if IS_PY34: list(sig.parameters)
... else: ['a', 'b', 'c', 'd']
['a', 'b', 'c', 'd']
>>> if IS_PY34: sig.parameters['c'].default == 123
... else: True
True
>>> if IS_PY34: sig.parameters['d'].default == 234
... else: True
True
"""
import inspect
return inspect.signature(inspect_signature) if IS_PY34 else None
def test_dict():
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment