Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass charm type to Context.manager #1444

Open
Batalex opened this issue Nov 1, 2024 · 1 comment · May be fixed by #1445
Open

Pass charm type to Context.manager #1444

Batalex opened this issue Nov 1, 2024 · 1 comment · May be fixed by #1445
Labels

Comments

@Batalex
Copy link

Batalex commented Nov 1, 2024

Hi,

When I am writing tests using the new testing framework formerly known as scenario, I find myself adding a line like this:

    with ctx(ctx.on.start(), state_in) as manager:
        charm = cast(KafkaCharm, manager.charm)  #  <-- This line...
        assert not charm.broker.healthy  # <-- ...gives me autocomplete and type checker validation

In larger code bases, this boilerplate adds up to numerous lines.

With a few tweaks to Context and Manager, we can make them variadic types and get this nice user experience:

Capture d’écran du 2024-10-31 17-27-55

If that's something you are interested in, I can open a PR. Have a look at my branch on ops-scenario, and let me know what you think!

@tonyandrewmeyer
Copy link
Contributor

If that's something you are interested in, I can open a PR. Have a look at my branch on ops-scenario, and let me know what you think!

That would be great, thanks!

@Batalex Batalex linked a pull request Nov 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants