-
Notifications
You must be signed in to change notification settings - Fork 26
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
Use mixin instead of having ProviderExtensionRegistryTestCase inherit from ExtensionRegistryTestCase #335
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good.
I think we can now remove this comment?:
envisage/envisage/tests/test_provider_extension_registry.py
Lines 511 to 512 in 1eccd80
# Overriden to test differing behavior between the provider registry and | |
# the base class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
with self.assertRaises(ValueError): | ||
registry.remove_extension_point_listener(listener) | ||
|
||
def test_set_extensions(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I am also investigating into these tests, and I realized that perhaps this test should be moved to the mixin too.
The mixin is useful for testing the compliance of the IExtensionRegistry interface: IExtensionRegistry.set_extensions
does not say subclass is allowed to raise and so the assumption is that it should not raise. ProviderExtensionRegistry
violates the interface requirement and makes set_extensions
always raise. So its test will also have to override the test, as a penalty for violating the interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the test mixin class should be repurposed to restrict itself to unsettable registry behaviour...
Nothing to do here. Please ignore me.
fixes #281
This PR pulls out methods from
test_extension_registry.ExtensionRegistryTestCase
into a mixin class calledtest_extension_registry_mixin.ExtensionRegistryTestMixin
which bothExtensionRegistryTestCase
andProviderExtensionRegistryTestCase
now inherit from.Test methods which were previously in
ExtensionRegistryTestCase
and overridden inProviderExtensionRegistryTestCase
have been left in these respective test cases and not included in the mixin.This should make it easier to add new tests to
ExtensionRegistryTestCase
.I searched for other TestCase subclassing but the only other occurrence I found was
EggBasedTestCase
being subclassed bytest_egg_plugin_manager.EggPluginManagerTestCase
. This I felt was fine to leave though becauseEggBasedTestCase
actually does not contain any tests, it simply contains helper methods ofsetUp
,_add_egg
, and_add_eggs_on_path
.Also, while working on this PR I did not see a test for https://github.com/enthought/envisage/blob/master/envisage/plugin_extension_registry.py
Such a test may want to use this mixin as well. Such a test case would really only need to additionally test the trait change handlers on the
plugin_manager
.