ASFHyP3 / hyp3-cookiecutter

Cookiecutter to quickly generate a new HyP3 Plugin
BSD 3-Clause "New" or "Revised" License
4 stars 4 forks source link

Fix entrypoint test #30

Closed forrestfwilliams closed 1 year ago

forrestfwilliams commented 1 year ago

After further thought, I'd like to keep at least one of the entrypoints. script_runner in test_entrypoints.py only works with entrypoints so we'll need to refactor the test if we don't keep one, and I think having an entrypoint will be important for most development workflows. I was leaning towards re-introducing the science entrypoint but could be persuaded to include the HyP3 one instead.

jhkennedy commented 1 year ago

Since the hyp3 entry point is already CLI accessible via python -m <package_name>, I don't see a need to register any other CLI scripts. We can get script_runner to work by making sure we're subprocessing out, not running in in-process mode; see the "Configuring script execution mode" section: https://pypi.org/project/pytest-console-scripts/

For example, this works:

@pytest.mark.script_launch_mode('subprocess')
def test_hyp3_isce2(script_runner):
    ret = script_runner.run('python', '-m', 'hyp3_isce2', '-h')
    assert ret.success

And instead of adding the decorator, we can just add:

 [pytest]
 script_launch_mode = subprocess

to the pyproject.toml to ensure we always subprocess out (from reading the docs, I think we want that anyways).