vendredi 22 janvier 2021

Testing a entry_point contribution

I am writing a Python module that specifies a set of entry_points, so other host modules can discover a new piece of functionality. I am following the setuptools approach specified at the official documentation.

As an example, the snippet below shows a contribution through sample.contribution named hello-world which points to timmins.hello_world attribute.

[options.entry_points]
sample.contribution =
    hello-world = timmins:hello_world

Let's suppose the host plugin defines a method like the following for loading sample.contributions extensions.

def load_contributions():
   ...

What I want to do is to write a test that ensures the entry_point is properly loaded by the host module. At this moment, the only way of testing such entry_point loading is through building a wheel and pip-install it. Once installed, the entry_point can be loaded sucessfully.

So, my question is ... Is there any way of adding the specified entry_points at setup.py (or setup.cfg) so they can be loaded during the tests execution? That is, a test for the module that defines the entry_point that returns the contributions when calling the load_contributions method

Aucun commentaire:

Enregistrer un commentaire