Removed the Requirement to Install Python and NodeJS (Now Bundled with Borealis)
This commit is contained in:
6
Dependencies/Python/Lib/test/test_inspect/__init__.py
vendored
Normal file
6
Dependencies/Python/Lib/test/test_inspect/__init__.py
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import os
|
||||
from test import support
|
||||
|
||||
|
||||
def load_tests(*args):
|
||||
return support.load_package_tests(os.path.dirname(__file__), *args)
|
120
Dependencies/Python/Lib/test/test_inspect/inspect_fodder.py
vendored
Normal file
120
Dependencies/Python/Lib/test/test_inspect/inspect_fodder.py
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
# line 1
|
||||
'A module docstring.'
|
||||
|
||||
import inspect
|
||||
# line 5
|
||||
|
||||
# line 7
|
||||
def spam(a, /, b, c, d=3, e=4, f=5, *g, **h):
|
||||
eggs(b + d, c + f)
|
||||
|
||||
# line 11
|
||||
def eggs(x, y):
|
||||
"A docstring."
|
||||
global fr, st
|
||||
fr = inspect.currentframe()
|
||||
st = inspect.stack()
|
||||
p = x
|
||||
q = y / 0
|
||||
|
||||
# line 20
|
||||
class StupidGit:
|
||||
"""A longer,
|
||||
|
||||
indented
|
||||
|
||||
docstring."""
|
||||
# line 27
|
||||
|
||||
def abuse(self, a, b, c):
|
||||
"""Another
|
||||
|
||||
\tdocstring
|
||||
|
||||
containing
|
||||
|
||||
\ttabs
|
||||
\t
|
||||
"""
|
||||
self.argue(a, b, c)
|
||||
# line 40
|
||||
def argue(self, a, b, c):
|
||||
try:
|
||||
spam(a, b, c)
|
||||
except BaseException as e:
|
||||
self.ex = e
|
||||
self.tr = inspect.trace()
|
||||
|
||||
@property
|
||||
def contradiction(self):
|
||||
'The automatic gainsaying.'
|
||||
pass
|
||||
|
||||
# line 53
|
||||
class MalodorousPervert(StupidGit):
|
||||
def abuse(self, a, b, c):
|
||||
pass
|
||||
|
||||
@property
|
||||
def contradiction(self):
|
||||
pass
|
||||
|
||||
Tit = MalodorousPervert
|
||||
|
||||
class ParrotDroppings:
|
||||
pass
|
||||
|
||||
class FesteringGob(MalodorousPervert, ParrotDroppings):
|
||||
def abuse(self, a, b, c):
|
||||
pass
|
||||
|
||||
def _getter(self):
|
||||
pass
|
||||
contradiction = property(_getter)
|
||||
|
||||
async def lobbest(grenade):
|
||||
pass
|
||||
|
||||
currentframe = inspect.currentframe()
|
||||
try:
|
||||
raise Exception()
|
||||
except BaseException as e:
|
||||
tb = e.__traceback__
|
||||
|
||||
class Callable:
|
||||
def __call__(self, *args):
|
||||
return args
|
||||
|
||||
def as_method_of(self, obj):
|
||||
from types import MethodType
|
||||
return MethodType(self, obj)
|
||||
|
||||
custom_method = Callable().as_method_of(42)
|
||||
del Callable
|
||||
|
||||
# line 95
|
||||
class WhichComments:
|
||||
# line 97
|
||||
# before f
|
||||
def f(self):
|
||||
# line 100
|
||||
# start f
|
||||
return 1
|
||||
# line 103
|
||||
# end f
|
||||
# line 105
|
||||
# after f
|
||||
|
||||
# before asyncf - line 108
|
||||
async def asyncf(self):
|
||||
# start asyncf
|
||||
return 2
|
||||
# end asyncf
|
||||
# after asyncf - line 113
|
||||
# end of WhichComments - line 114
|
||||
# after WhichComments - line 115
|
||||
|
||||
# Test that getsource works on a line that includes
|
||||
# a closing parenthesis with the opening paren being in another line
|
||||
(
|
||||
); after_closing = lambda: 1
|
371
Dependencies/Python/Lib/test/test_inspect/inspect_fodder2.py
vendored
Normal file
371
Dependencies/Python/Lib/test/test_inspect/inspect_fodder2.py
vendored
Normal file
@ -0,0 +1,371 @@
|
||||
# line 1
|
||||
def wrap(foo=None):
|
||||
def wrapper(func):
|
||||
return func
|
||||
return wrapper
|
||||
|
||||
# line 7
|
||||
def replace(func):
|
||||
def insteadfunc():
|
||||
print('hello')
|
||||
return insteadfunc
|
||||
|
||||
# line 13
|
||||
@wrap()
|
||||
@wrap(wrap)
|
||||
def wrapped():
|
||||
pass
|
||||
|
||||
# line 19
|
||||
@replace
|
||||
def gone():
|
||||
pass
|
||||
|
||||
# line 24
|
||||
oll = lambda m: m
|
||||
|
||||
# line 27
|
||||
tll = lambda g: g and \
|
||||
g and \
|
||||
g
|
||||
|
||||
# line 32
|
||||
tlli = lambda d: d and \
|
||||
d
|
||||
|
||||
# line 36
|
||||
def onelinefunc(): pass
|
||||
|
||||
# line 39
|
||||
def manyargs(arg1, arg2,
|
||||
arg3, arg4): pass
|
||||
|
||||
# line 43
|
||||
def twolinefunc(m): return m and \
|
||||
m
|
||||
|
||||
# line 47
|
||||
a = [None,
|
||||
lambda x: x,
|
||||
None]
|
||||
|
||||
# line 52
|
||||
def setfunc(func):
|
||||
globals()["anonymous"] = func
|
||||
setfunc(lambda x, y: x*y)
|
||||
|
||||
# line 57
|
||||
def with_comment(): # hello
|
||||
world
|
||||
|
||||
# line 61
|
||||
multiline_sig = [
|
||||
lambda x, \
|
||||
y: x+y,
|
||||
None,
|
||||
]
|
||||
|
||||
# line 68
|
||||
def func69():
|
||||
class cls70:
|
||||
def func71():
|
||||
pass
|
||||
return cls70
|
||||
extra74 = 74
|
||||
|
||||
# line 76
|
||||
def func77(): pass
|
||||
(extra78, stuff78) = 'xy'
|
||||
extra79 = 'stop'
|
||||
|
||||
# line 81
|
||||
class cls82:
|
||||
def func83(): pass
|
||||
(extra84, stuff84) = 'xy'
|
||||
extra85 = 'stop'
|
||||
|
||||
# line 87
|
||||
def func88():
|
||||
# comment
|
||||
return 90
|
||||
|
||||
# line 92
|
||||
def f():
|
||||
class X:
|
||||
def g():
|
||||
"doc"
|
||||
return 42
|
||||
return X
|
||||
method_in_dynamic_class = f().g
|
||||
|
||||
#line 101
|
||||
def keyworded(*arg1, arg2=1):
|
||||
pass
|
||||
|
||||
#line 105
|
||||
def annotated(arg1: list):
|
||||
pass
|
||||
|
||||
#line 109
|
||||
def keyword_only_arg(*, arg):
|
||||
pass
|
||||
|
||||
@wrap(lambda: None)
|
||||
def func114():
|
||||
return 115
|
||||
|
||||
class ClassWithMethod:
|
||||
def method(self):
|
||||
pass
|
||||
|
||||
from functools import wraps
|
||||
|
||||
def decorator(func):
|
||||
@wraps(func)
|
||||
def fake():
|
||||
return 42
|
||||
return fake
|
||||
|
||||
#line 129
|
||||
@decorator
|
||||
def real():
|
||||
return 20
|
||||
|
||||
#line 134
|
||||
class cls135:
|
||||
def func136():
|
||||
def func137():
|
||||
never_reached1
|
||||
never_reached2
|
||||
|
||||
# line 141
|
||||
class cls142:
|
||||
a = """
|
||||
class cls149:
|
||||
...
|
||||
"""
|
||||
|
||||
# line 148
|
||||
class cls149:
|
||||
|
||||
def func151(self):
|
||||
pass
|
||||
|
||||
'''
|
||||
class cls160:
|
||||
pass
|
||||
'''
|
||||
|
||||
# line 159
|
||||
class cls160:
|
||||
|
||||
def func162(self):
|
||||
pass
|
||||
|
||||
# line 165
|
||||
class cls166:
|
||||
a = '''
|
||||
class cls175:
|
||||
...
|
||||
'''
|
||||
|
||||
# line 172
|
||||
class cls173:
|
||||
|
||||
class cls175:
|
||||
pass
|
||||
|
||||
# line 178
|
||||
class cls179:
|
||||
pass
|
||||
|
||||
# line 182
|
||||
class cls183:
|
||||
|
||||
class cls185:
|
||||
|
||||
def func186(self):
|
||||
pass
|
||||
|
||||
def class_decorator(cls):
|
||||
return cls
|
||||
|
||||
# line 193
|
||||
@class_decorator
|
||||
@class_decorator
|
||||
class cls196:
|
||||
|
||||
@class_decorator
|
||||
@class_decorator
|
||||
class cls200:
|
||||
pass
|
||||
|
||||
class cls203:
|
||||
class cls204:
|
||||
class cls205:
|
||||
pass
|
||||
class cls207:
|
||||
class cls205:
|
||||
pass
|
||||
|
||||
# line 211
|
||||
def func212():
|
||||
class cls213:
|
||||
pass
|
||||
return cls213
|
||||
|
||||
# line 217
|
||||
class cls213:
|
||||
def func219(self):
|
||||
class cls220:
|
||||
pass
|
||||
return cls220
|
||||
|
||||
# line 224
|
||||
async def func225():
|
||||
class cls226:
|
||||
pass
|
||||
return cls226
|
||||
|
||||
# line 230
|
||||
class cls226:
|
||||
async def func232(self):
|
||||
class cls233:
|
||||
pass
|
||||
return cls233
|
||||
|
||||
if True:
|
||||
class cls238:
|
||||
class cls239:
|
||||
'''if clause cls239'''
|
||||
else:
|
||||
class cls238:
|
||||
class cls239:
|
||||
'''else clause 239'''
|
||||
pass
|
||||
|
||||
#line 247
|
||||
def positional_only_arg(a, /):
|
||||
pass
|
||||
|
||||
#line 251
|
||||
def all_markers(a, b, /, c, d, *, e, f):
|
||||
pass
|
||||
|
||||
# line 255
|
||||
def all_markers_with_args_and_kwargs(a, b, /, c, d, *args, e, f, **kwargs):
|
||||
pass
|
||||
|
||||
#line 259
|
||||
def all_markers_with_defaults(a, b=1, /, c=2, d=3, *, e=4, f=5):
|
||||
pass
|
||||
|
||||
# line 263
|
||||
def deco_factory(**kwargs):
|
||||
def deco(f):
|
||||
@wraps(f)
|
||||
def wrapper(*a, **kwd):
|
||||
kwd.update(kwargs)
|
||||
return f(*a, **kwd)
|
||||
return wrapper
|
||||
return deco
|
||||
|
||||
@deco_factory(foo=(1 + 2), bar=lambda: 1)
|
||||
def complex_decorated(foo=0, bar=lambda: 0):
|
||||
return foo + bar()
|
||||
|
||||
# line 276
|
||||
parenthesized_lambda = (
|
||||
lambda: ())
|
||||
parenthesized_lambda2 = [
|
||||
lambda: ()][0]
|
||||
parenthesized_lambda3 = {0:
|
||||
lambda: ()}[0]
|
||||
|
||||
# line 285
|
||||
post_line_parenthesized_lambda1 = (lambda: ()
|
||||
)
|
||||
|
||||
# line 289
|
||||
nested_lambda = (
|
||||
lambda right: [].map(
|
||||
lambda length: ()))
|
||||
|
||||
# line 294
|
||||
if True:
|
||||
class cls296:
|
||||
def f():
|
||||
pass
|
||||
else:
|
||||
class cls296:
|
||||
def g():
|
||||
pass
|
||||
|
||||
# line 304
|
||||
if False:
|
||||
class cls310:
|
||||
def f():
|
||||
pass
|
||||
else:
|
||||
class cls310:
|
||||
def g():
|
||||
pass
|
||||
|
||||
# line 314
|
||||
class ClassWithCodeObject:
|
||||
import sys
|
||||
code = sys._getframe(0).f_code
|
||||
|
||||
import enum
|
||||
|
||||
# line 321
|
||||
class enum322(enum.Enum):
|
||||
A = 'a'
|
||||
|
||||
# line 325
|
||||
class enum326(enum.IntEnum):
|
||||
A = 1
|
||||
|
||||
# line 329
|
||||
class flag330(enum.Flag):
|
||||
A = 1
|
||||
|
||||
# line 333
|
||||
class flag334(enum.IntFlag):
|
||||
A = 1
|
||||
|
||||
# line 337
|
||||
simple_enum338 = enum.Enum('simple_enum338', 'A')
|
||||
simple_enum339 = enum.IntEnum('simple_enum339', 'A')
|
||||
simple_flag340 = enum.Flag('simple_flag340', 'A')
|
||||
simple_flag341 = enum.IntFlag('simple_flag341', 'A')
|
||||
|
||||
import typing
|
||||
|
||||
# line 345
|
||||
class nt346(typing.NamedTuple):
|
||||
x: int
|
||||
y: int
|
||||
|
||||
# line 350
|
||||
nt351 = typing.NamedTuple('nt351', (('x', int), ('y', int)))
|
||||
|
||||
# line 353
|
||||
class td354(typing.TypedDict):
|
||||
x: int
|
||||
y: int
|
||||
|
||||
# line 358
|
||||
td359 = typing.TypedDict('td359', (('x', int), ('y', int)))
|
||||
|
||||
import dataclasses
|
||||
|
||||
# line 363
|
||||
@dataclasses.dataclass
|
||||
class dc364:
|
||||
x: int
|
||||
y: int
|
||||
|
||||
# line 369
|
||||
dc370 = dataclasses.make_dataclass('dc370', (('x', int), ('y', int)))
|
||||
dc371 = dataclasses.make_dataclass('dc370', (('x', int), ('y', int)), module=__name__)
|
28
Dependencies/Python/Lib/test/test_inspect/inspect_stock_annotations.py
vendored
Normal file
28
Dependencies/Python/Lib/test/test_inspect/inspect_stock_annotations.py
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
a:int=3
|
||||
b:str="foo"
|
||||
|
||||
class MyClass:
|
||||
a:int=4
|
||||
b:str="bar"
|
||||
def __init__(self, a, b):
|
||||
self.a = a
|
||||
self.b = b
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, MyClass) and self.a == other.a and self.b == other.b
|
||||
|
||||
def function(a:int, b:str) -> MyClass:
|
||||
return MyClass(a, b)
|
||||
|
||||
|
||||
def function2(a:int, b:"str", c:MyClass) -> MyClass:
|
||||
pass
|
||||
|
||||
|
||||
def function3(a:"int", b:"str", c:"MyClass"):
|
||||
pass
|
||||
|
||||
|
||||
class UnannotatedClass:
|
||||
pass
|
||||
|
||||
def unannotated_function(a, b, c): pass
|
34
Dependencies/Python/Lib/test/test_inspect/inspect_stringized_annotations.py
vendored
Normal file
34
Dependencies/Python/Lib/test/test_inspect/inspect_stringized_annotations.py
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
from __future__ import annotations
|
||||
|
||||
a:int=3
|
||||
b:str="foo"
|
||||
|
||||
class MyClass:
|
||||
a:int=4
|
||||
b:str="bar"
|
||||
def __init__(self, a, b):
|
||||
self.a = a
|
||||
self.b = b
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, MyClass) and self.a == other.a and self.b == other.b
|
||||
|
||||
def function(a:int, b:str) -> MyClass:
|
||||
return MyClass(a, b)
|
||||
|
||||
|
||||
def function2(a:int, b:"str", c:MyClass) -> MyClass:
|
||||
pass
|
||||
|
||||
|
||||
def function3(a:"int", b:"str", c:"MyClass"):
|
||||
pass
|
||||
|
||||
|
||||
class UnannotatedClass:
|
||||
pass
|
||||
|
||||
def unannotated_function(a, b, c): pass
|
||||
|
||||
class MyClassWithLocalAnnotations:
|
||||
mytype = int
|
||||
x: mytype
|
3
Dependencies/Python/Lib/test/test_inspect/inspect_stringized_annotations_2.py
vendored
Normal file
3
Dependencies/Python/Lib/test/test_inspect/inspect_stringized_annotations_2.py
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
from __future__ import annotations
|
||||
|
||||
def foo(a, b, c): pass
|
87
Dependencies/Python/Lib/test/test_inspect/inspect_stringized_annotations_pep695.py
vendored
Normal file
87
Dependencies/Python/Lib/test/test_inspect/inspect_stringized_annotations_pep695.py
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
from __future__ import annotations
|
||||
from typing import Callable, Unpack
|
||||
|
||||
|
||||
class A[T, *Ts, **P]:
|
||||
x: T
|
||||
y: tuple[*Ts]
|
||||
z: Callable[P, str]
|
||||
|
||||
|
||||
class B[T, *Ts, **P]:
|
||||
T = int
|
||||
Ts = str
|
||||
P = bytes
|
||||
x: T
|
||||
y: Ts
|
||||
z: P
|
||||
|
||||
|
||||
Eggs = int
|
||||
Spam = str
|
||||
|
||||
|
||||
class C[Eggs, **Spam]:
|
||||
x: Eggs
|
||||
y: Spam
|
||||
|
||||
|
||||
def generic_function[T, *Ts, **P](
|
||||
x: T, *y: Unpack[Ts], z: P.args, zz: P.kwargs
|
||||
) -> None: ...
|
||||
|
||||
|
||||
def generic_function_2[Eggs, **Spam](x: Eggs, y: Spam): pass
|
||||
|
||||
|
||||
class D:
|
||||
Foo = int
|
||||
Bar = str
|
||||
|
||||
def generic_method[Foo, **Bar](
|
||||
self, x: Foo, y: Bar
|
||||
) -> None: ...
|
||||
|
||||
def generic_method_2[Eggs, **Spam](self, x: Eggs, y: Spam): pass
|
||||
|
||||
|
||||
# Eggs is `int` in globals, a TypeVar in type_params, and `str` in locals:
|
||||
class E[Eggs]:
|
||||
Eggs = str
|
||||
x: Eggs
|
||||
|
||||
|
||||
|
||||
def nested():
|
||||
from types import SimpleNamespace
|
||||
from inspect import get_annotations
|
||||
|
||||
Eggs = bytes
|
||||
Spam = memoryview
|
||||
|
||||
|
||||
class F[Eggs, **Spam]:
|
||||
x: Eggs
|
||||
y: Spam
|
||||
|
||||
def generic_method[Eggs, **Spam](self, x: Eggs, y: Spam): pass
|
||||
|
||||
|
||||
def generic_function[Eggs, **Spam](x: Eggs, y: Spam): pass
|
||||
|
||||
|
||||
# Eggs is `int` in globals, `bytes` in the function scope,
|
||||
# a TypeVar in the type_params, and `str` in locals:
|
||||
class G[Eggs]:
|
||||
Eggs = str
|
||||
x: Eggs
|
||||
|
||||
|
||||
return SimpleNamespace(
|
||||
F=F,
|
||||
F_annotations=get_annotations(F, eval_str=True),
|
||||
F_meth_annotations=get_annotations(F.generic_method, eval_str=True),
|
||||
G_annotations=get_annotations(G, eval_str=True),
|
||||
generic_func=generic_function,
|
||||
generic_func_annotations=get_annotations(generic_function, eval_str=True)
|
||||
)
|
6276
Dependencies/Python/Lib/test/test_inspect/test_inspect.py
vendored
Normal file
6276
Dependencies/Python/Lib/test/test_inspect/test_inspect.py
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user