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

Use mixin instead of having ProviderExtensionRegistryTestCase inherit from ExtensionRegistryTestCase #335

Merged
merged 4 commits into from
Oct 22, 2020

Conversation

aaronayres35
Copy link
Contributor

fixes #281

This PR pulls out methods from test_extension_registry.ExtensionRegistryTestCase into a mixin class called test_extension_registry_mixin.ExtensionRegistryTestMixin which both ExtensionRegistryTestCase and ProviderExtensionRegistryTestCase now inherit from.

Test methods which were previously in ExtensionRegistryTestCase and overridden in ProviderExtensionRegistryTestCase 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 by test_egg_plugin_manager.EggPluginManagerTestCase. This I felt was fine to leave though because EggBasedTestCase actually does not contain any tests, it simply contains helper methods of setUp, _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.

Copy link
Contributor

@kitchoi kitchoi left a 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?:

# Overriden to test differing behavior between the provider registry and
# the base class.

envisage/tests/test_extension_registry_mixin.py Outdated Show resolved Hide resolved
Copy link
Contributor

@kitchoi kitchoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aaronayres35 aaronayres35 merged commit c64feba into master Oct 22, 2020
@aaronayres35 aaronayres35 deleted the fix-281-testcase-inheritance branch October 22, 2020 13:26

with self.assertRaises(ValueError):
registry.remove_extension_point_listener(listener)

def test_set_extensions(self):
Copy link
Contributor

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.

Copy link
Contributor

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.

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

Successfully merging this pull request may close these issues.

Cleanup: don't have TestCase classes inherit from other TestCase classes
2 participants