Reputation: 9473
I built a python application (the "host" app) that defines a setuptools
entry-point, so that it can be extended. Plugin-authors then have to add the following into their setup.py
file:
setup(
# ...
entry_points = {
'myapp.plugins':
['plugin_1 = <foo.plugin.module>:<plugin-install-func>']
}
)
In order to test my setup, i have to
pip
to install it, sys.path
and invoke pkg_resources.working_set.add_entry(package_dir)
[*],pip
to uninstall the package, andsys.path
,And a separate package is needed for each test-case, if different functionality must be validated.
This whole testing-rig is rather verbose and clumsy.
Is there a more elegant way to write test-cases for setuptools
entry-point plugins?
[*] Note: Installing a wheels or using pip* in develop mode with pip install -e <plugin-package>
would not activate the plugin on the same interpreter on Linux; or at least not without appending afterwards the package folder in sys.path
.
On Windows, the above problem exists only on develop mode.
Upvotes: 12
Views: 1064
Reputation: 36
I had a same problem and resolved by a dirty hack to build and 'pip install' the plugin package to test, into a tox's environment and run tests in that environment.
Upvotes: 1