Skip to content

Commit

Permalink
Remove sys.exit call in inspect_objects() and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
beeankha committed Apr 3, 2024
1 parent 59e67e6 commit f9c4ea7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion conda_build/inspect_pkg.py
Expand Up @@ -315,7 +315,9 @@ def inspect_objects(
groupby: str = "package",
):
if not on_mac:
sys.exit("Error: conda inspect objects is only implemented in OS X")
raise CondaBuildUserError(
"Error: conda inspect objects is only implemented in OS X"
)

prefix = Path(prefix)
installed = {prec.name: prec for prec in PrefixData(str(prefix)).iter_records()}
Expand Down
10 changes: 8 additions & 2 deletions tests/test_inspect_pkg.py
Expand Up @@ -11,8 +11,8 @@
from conda.core.prefix_data import PrefixData

from conda_build.exceptions import CondaBuildUserError
from conda_build.inspect_pkg import inspect_linkages, which_package
from conda_build.utils import on_win
from conda_build.inspect_pkg import inspect_linkages, inspect_objects, which_package
from conda_build.utils import on_mac, on_win


def test_which_package(tmp_path: Path):
Expand Down Expand Up @@ -289,3 +289,9 @@ def test_inspect_linkages_on_win():
def test_inspect_linkages_not_installed():
with pytest.raises(CondaBuildUserError):
inspect_linkages(["not_installed_pkg"])


@pytest.mark.skipif(on_mac, reason="inspect_objects is only available on macOS")
def test_inspect_objects_not_on_mac():
with pytest.raises(CondaBuildUserError):
inspect_objects([])

0 comments on commit f9c4ea7

Please sign in to comment.