pulumi/sdk/python/lib/test/langhost/source_position
Fraser Waters 4cbc3e46b2
Fix python source positions for new SDKs (#18575)
Fixes https://github.com/pulumi/pulumi/issues/18478

At some point python SDKs started using an `__internal_init__` method as
part of generated resource constructors. This changed the expected
height of user code in the stack traces we grab for setting
`sourcePosition` and our tests never picked this up because they used a
handwritten SDK that only had an `__init__` method.

This updates the test so that one resource has an `__internal_init__`
that is called by `__init__` and then fixes `get_source_position` so it
can handle both cases. It does this by looking up the stack for the
third `__init__` call and then picking the frame above that.

Still a bit brittle, but I think it's the best you can do by just
looking at function names, and we're probably not going to add anymore
classes into the inheritance chain.
2025-02-12 18:21:46 +00:00
..
__init__.py [sdk/*] Add support for resource source positions 2023-07-13 16:46:04 -07:00
__main__.py Fix python source positions for new SDKs (#18575) 2025-02-12 18:21:46 +00:00
test_source_position.py Fix python source positions for new SDKs (#18575) 2025-02-12 18:21:46 +00:00