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

Function test_external_constructor_doc

sdk/python/tests/mod/test_registration.py:165–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

163
164
165def test_external_constructor_doc():
166 mod = Module()
167
168 @mod.object_type
169 class External:
170 """external docstring"""
171
172 foo: Annotated[str, Doc("a foo walks into a bar")] = "bar"
173
174 @mod.function
175 def bar(self) -> str:
176 return self.foo
177
178 @mod.object_type
179 class Test:
180 external = mod.function()(External)
181 alternative = mod.function(doc="still external")(External)
182
183 obj = mod.get_object("Test")
184 assert obj.functions["external"].doc == "external docstring"
185 assert obj.functions["alternative"].doc == "still external"
186 # all functions point to the same constructor, with the same arguments
187 for fn in obj.functions.values():
188 for param in fn.parameters.values():
189 assert param.name == "foo"
190 assert param.doc == "a foo walks into a bar"
191 assert param.default_value == dagger.JSON('"bar"')
192
193
194def test_external_alt_constructor_doc():

Callers

nothing calls this directly

Calls 4

get_objectMethod · 0.95
ModuleClass · 0.90
valuesMethod · 0.45
JSONMethod · 0.45

Tested by

no test coverage detected