-
Notifications
You must be signed in to change notification settings - Fork 20
Closed
Labels
part:testsAffects the unit, integration and performance (benchmarks) testsAffects the unit, integration and performance (benchmarks) testspriority:lowThis should be addressed only if there is nothing else on the tableThis should be addressed only if there is nothing else on the tabletype:bugSomething isn't workingSomething isn't working
Milestone
Description
What happened?
Originally created by @ela-kotulska-frequenz
We added fixture to change the restart_limit in actors, but we didn't enable it for all actors in unit tests.
It looks like if we use this fixture, we can't pass any arguments to the tests functions.
Example:
If class TestActorConfigManager: derives after (IsolatedAsyncioTestCase) then the tests fails with error:
self = <tests.mos_framework.configs.test_config_manager.TestActorConfigManager testMethod=test_update>
func = <bound method TestActorConfigManager.test_update of <tests.mos_framework.configs.test_config_manager.TestActorConfigManager testMethod=test_update>>
args = (), kwargs = {}
def _callMaybeAsync(self, func, /, *args, **kwargs):
assert self._asyncioTestLoop is not None
> ret = func(*args, **kwargs)
E TypeError: test_update() missing 1 required positional argument: 'config_file'
What did you expect instead?
The restart_limit is overridden correctly.
Affected version(s)
All
Affected part(s)
Unit, integration and performance tests (part:tests)
Extra information
Fixture to change restart_limit:
frequenz-sdk-python/tests/conftest.py
Lines 18 to 31 in 20e1dff
| @pytest.fixture(scope="session", autouse=True) | |
| def disable_actor_auto_restart(): # type: ignore | |
| """Disable auto-restart of actors while running tests. | |
| Since this is auto-use, the yield part (and restore of the variable) is not | |
| strictly needed, but we leave it as an example. | |
| Note: Test class must derive after unittest.IsolatedAsyncioTestCase. | |
| Otherwise this fixture won't run. | |
| """ | |
| original_restart_limit = decorator.BaseActor.restart_limit | |
| decorator.BaseActor.restart_limit = 0 | |
| yield | |
| decorator.BaseActor.restart_limit = original_restart_limit |
Metadata
Metadata
Assignees
Labels
part:testsAffects the unit, integration and performance (benchmarks) testsAffects the unit, integration and performance (benchmarks) testspriority:lowThis should be addressed only if there is nothing else on the tableThis should be addressed only if there is nothing else on the tabletype:bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done