diff --git a/swh/model/cli.py b/swh/model/cli.py index 8ac925079d9442cfa0b75afb13eae4bb43b019fe..312a0247b35d1d0830d0824b3cec6638faa366e9 100644 --- a/swh/model/cli.py +++ b/swh/model/cli.py @@ -11,7 +11,12 @@ from typing import Dict, List, Optional # control import click -from swh.core.cli import swh as swh_cli_group +try: + from swh.core.cli import swh as swh_cli_group +except ImportError: + # stub so that swh-identify can be used when swh-core isn't installed + swh_cli_group = click # type: ignore + from swh.model.identifiers import CoreSWHID, ObjectType CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) diff --git a/tox.ini b/tox.ini index bffcdfafd6924e3f97839d387b9611ab495ebaff..1ea702f9571875aabb2279d34a6f9e1c316fcb13 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=black,flake8,mypy,py3 +envlist=black,flake8,mypy,py3,identify [testenv] extras = @@ -12,6 +12,15 @@ commands = {envsitepackagesdir}/swh/model \ --cov-branch {posargs} +[testenv:identify] +# no 'extras = testing', as it would install swh-core; +# and this test is designed to check 'swh-identify' does not depend on swh-core. +extras = +deps = + -r requirements-test.txt +commands = + pytest {envsitepackagesdir}/swh/model/tests/test_cli.py + [testenv:black] skip_install = true deps =