Python unit testing

How does one unit test python stacks? I dont see any examples in the codebase. Anyone have any pointers or links?

thanks!

Hi there:

Good news: unit testing support for Python just shipped with our latest release last night. You can find documentation here and a few more examples here. (Shoutout to our summer intern, Mark, for building out this feature for us!)

Thanks for adding support for python testing. There is currently no way to specify a context for the unit tests. We heavily use context params in cdktf.json and access them inside our stacks using app.node.try_get_context.

The Testing.app does not have any way to pass in a context. Tried using app.node.set_context, but that does not work either with Testing.app.

Any pointers on how we can test python stacks that use context parameters?

thanks

Hi @pchaganti :wave:

Could you share a short example which does not work? The Testing tool uses app.node.setContext() internally (in TypeScript, but set_context in Python should equal that same call).