You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR contains no changes of the behaviour. The public signatures remain exactly the same.
Reason: With the old approach (from kopf.mod import func; x = func()), it becomes more and more difficult to patch & mock the cross-module functions, as the patches are needed at where the functions are used, not where they are implemented.
Tracking of what is imported where is difficult on its own, and also implies the knowledge of how the code is done on the multi-level sequences of calls. This violates the concept of the tests testing the behaviour rather than the specific implementation of it.
Now (with this PR: from kopf import mod; x = mod.func()), the functions & constants are patched at where they are implemented (in their own modules), and all places around the code always refer to the function via its module name. We assume that we never mock the whole modules.
The new importing approach is not applied to the tests, and they continue to import individual functions/constants/classes for 2 reasons:
The tests use those functions/classes as the objects-under-test, so they need the original functions, not their mocks.
To ensure that the tests remain (mostly) unchanged — for easier PR review.
Some renames were necessary to ensure absence of naming conflicts:
kopf.reactor.registry is now kopf.reactor.registries, to not collide with the registry= kwarg. peering= kwarg is now peering_name= kwarg, to not collide with kopf.reactor.peering module (also implies that the peering modes can be extended with something else in addition to the names).
kopf.structs.progress is now kopf.structs.status.
The text was updated successfully, but these errors were encountered:
This is a refactoring to switch to the Google Python Style Guide for imports.
This PR contains no changes of the behaviour.
The public signatures remain exactly the same.
Reason: With the old approach (
from kopf.mod import func; x = func()
), it becomes more and more difficult to patch & mock the cross-module functions, as the patches are needed at where the functions are used, not where they are implemented.Tracking of what is imported where is difficult on its own, and also implies the knowledge of how the code is done on the multi-level sequences of calls. This violates the concept of the tests testing the behaviour rather than the specific implementation of it.
Now (with this PR:
from kopf import mod; x = mod.func()
), the functions & constants are patched at where they are implemented (in their own modules), and all places around the code always refer to the function via its module name. We assume that we never mock the whole modules.The new importing approach is not applied to the tests, and they continue to import individual functions/constants/classes for 2 reasons:
Some renames were necessary to ensure absence of naming conflicts:
kopf.reactor.registry
is nowkopf.reactor.registries
, to not collide with theregistry=
kwarg.peering=
kwarg is nowpeering_name=
kwarg, to not collide withkopf.reactor.peering
module (also implies that the peering modes can be extended with something else in addition to the names).kopf.structs.progress
is nowkopf.structs.status
.The text was updated successfully, but these errors were encountered: