inmanta / pytest-inmanta-lsm

Pytest Extesion for LSM
Other
0 stars 1 forks source link

add support for testing module with extra #269

Open sanderr opened 1 year ago

sanderr commented 1 year ago

V2 modules may have extras / optional dependencies.The project and remote_orchestrator fixtures currently do not support this: the module is rsynced to the server and installed in editable mode, but no extras can be supplied. A generic fix could be to provide a method on Project to add a dependency to requirements.txt.

For example, suppose the module mymodule has an extra named myextra, the conftest.py could define a fixture as follows:

@pytest.fixture
def project_with_extra(project):
    project.add_dependency("mymodule[myextra]")

Then, test cases that want to test the behavior when the extra is present would just have to use this project_with_extra fixture instead of the normal project fixture.

The connect module is an example of a module with an extra. At the time of writing it is being converted to a v2 module and an approach similar to the one described above is being implemented in the module's tests itself.

sanderr commented 1 year ago

WIP on issue/269-project-set-requirements (on pytest-inmanta). Will pick it up again after my holidays unless someone gets to it first.