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

Means to build charm with session scope #40

Open
sed-i opened this issue Dec 17, 2021 · 1 comment
Open

Means to build charm with session scope #40

sed-i opened this issue Dec 17, 2021 · 1 comment

Comments

@sed-i
Copy link
Contributor

sed-i commented Dec 17, 2021

The ops_test fixture has module scope, and it is very convenient to have the model destroyed when I move from one test_*.py to another.
However, I use the same *.charm in all my test_*.py, so fixture such as

@pytest.fixture(scope="module")
async def charm_under_test(ops_test: OpsTest) -> Path:
    """Charm used for integration testing."""
    return = await ops_test.build_charm(".")

would still cause my charm to be built again and again as the test progresses throughout the test_*.py files.

It would be handy to be able to have a charm "persist" without tricks such as

global _path_to_built_charm
if _path_to_built_charm is None:
    _path_to_built_charm = await ops_test.build_charm(".")

Which brings me to a question: I wonder if the design approach is:

  1. the higher flexibility of having the entire ops_test in module scope is desirable
  2. having the same charm being rebuilt every time is an ok price to pay
  3. tests should still be divided into modules rather than one big file with await ops_test.model.reset() at the end of every test function
@PietroPasotti
Copy link
Contributor

+1 on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants