diff options
Diffstat (limited to 'Lib/test/_code_definitions.py')
-rw-r--r-- | Lib/test/_code_definitions.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Lib/test/_code_definitions.py b/Lib/test/_code_definitions.py index 06cf6a10231..c3daa0dccf5 100644 --- a/Lib/test/_code_definitions.py +++ b/Lib/test/_code_definitions.py @@ -12,6 +12,50 @@ def spam_minimal(): return +def spam_with_builtins(): + x = 42 + values = (42,) + checks = tuple(callable(v) for v in values) + res = callable(values), tuple(values), list(values), checks + print(res) + + +def spam_with_globals_and_builtins(): + func1 = spam + func2 = spam_minimal + funcs = (func1, func2) + checks = tuple(callable(f) for f in funcs) + res = callable(funcs), tuple(funcs), list(funcs), checks + print(res) + + +def spam_args_attrs_and_builtins(a, b, /, c, d, *args, e, f, **kwargs): + if args.__len__() > 2: + return None + return a, b, c, d, e, f, args, kwargs + + +def spam_returns_arg(x): + return x + + +def spam_with_inner_not_closure(): + def eggs(): + pass + eggs() + + +def spam_with_inner_closure(): + x = 42 + def eggs(): + print(x) + eggs() + + +def spam_annotated(a: int, b: str, c: object) -> tuple: + return a, b, c + + def spam_full(a, b, /, c, d:int=1, *args, e, f:object=None, **kwargs) -> tuple: # arg defaults, kwarg defaults # annotations @@ -98,6 +142,13 @@ ham_C_closure, *_ = eggs_closure_C(2) TOP_FUNCTIONS = [ # shallow spam_minimal, + spam_with_builtins, + spam_with_globals_and_builtins, + spam_args_attrs_and_builtins, + spam_returns_arg, + spam_with_inner_not_closure, + spam_with_inner_closure, + spam_annotated, spam_full, spam, # outer func |