MCPcopy Create free account
hub / github.com/dagger/dagger / TestSignatures

Method TestSignatures

core/integration/module_python_test.go:1027–1160  ·  view source on GitHub ↗
(ctx context.Context, t *testctx.T)

Source from the content-addressed store, hash-verified

1025}
1026
1027func (PythonSuite) TestSignatures(ctx context.Context, t *testctx.T) {
1028 c := connect(ctx, t)
1029
1030 modGen := pythonModInit(t, c, `
1031 from collections.abc import Sequence
1032 from typing import Optional
1033
1034 from dagger import field, function, object_type
1035
1036 @object_type
1037 class Test:
1038 @function
1039 def hello(self) -> str:
1040 return "hello"
1041
1042 @function
1043 def hello_none(self) -> None:
1044 ...
1045
1046 @function
1047 def hello_void(self):
1048 ...
1049
1050 @function
1051 def echo(self, msg: str) -> str:
1052 return msg
1053
1054 @function
1055 def echo_default(self, msg: str = "hello") -> str:
1056 return msg
1057
1058 @function
1059 def echo_old_optional(self, msg: Optional[str] = None) -> str:
1060 return "hello" if msg is None else msg
1061
1062 @function
1063 def echo_optional(self, msg: str | None = None) -> str:
1064 return "hello" if msg is None else msg
1065
1066 @function
1067 def echo_sequence(self, msg: Sequence[str]) -> str:
1068 return self.echo("+".join(msg))
1069
1070 @function
1071 def echo_tuple(self, msg: tuple[str, ...]) -> str:
1072 return self.echo_sequence(msg)
1073
1074 @function
1075 def echo_list(self, msg: list[str]) -> str:
1076 return self.echo_sequence(msg)
1077
1078 @function
1079 def echo_opts(self, msg: str, suffix: str = "", times: int = 1) -> str:
1080 return (msg + suffix) * times
1081 `)
1082
1083 for _, tc := range []struct {
1084 name string

Callers

nothing calls this directly

Calls 6

pythonModInitFunction · 0.85
daggerQueryFunction · 0.85
connectFunction · 0.70
RunMethod · 0.65
StdoutMethod · 0.45
WithMethod · 0.45

Tested by

no test coverage detected