From cd9751d25eed1bcad5d79b155de543cc195b3619 Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Fri, 9 Aug 2024 13:30:46 -0400 Subject: [PATCH] Replace sys.exit call in convert.py with a return statement, update unit tests --- conda_build/convert.py | 3 +-- tests/test_api_convert.py | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/conda_build/convert.py b/conda_build/convert.py index 75803a4c83..628ba95109 100644 --- a/conda_build/convert.py +++ b/conda_build/convert.py @@ -12,7 +12,6 @@ import os import re import shutil -import sys import tarfile import tempfile from pathlib import Path @@ -819,7 +818,7 @@ def conda_convert( else: for c_extension in imports: print(c_extension) - sys.exit() + return if not show_imports and len(platforms) == 0: raise CondaBuildUserError( diff --git a/tests/test_api_convert.py b/tests/test_api_convert.py index a2651ceba0..9b0526ed54 100644 --- a/tests/test_api_convert.py +++ b/tests/test_api_convert.py @@ -61,8 +61,7 @@ def test_show_imports(base_platform, package, capfd): download(f, fn) for platform in platforms: - with pytest.raises(SystemExit): - api.convert(fn, platforms=platform, show_imports=True) + api.convert(fn, platforms=platform, show_imports=True) output, error = capfd.readouterr() @@ -81,8 +80,7 @@ def test_no_imports_found(base_platform, package, capfd): fn = f"{package_name}-py36_0.tar.bz2" download(f, fn) - with pytest.raises(SystemExit): - api.convert(fn, platforms=None, show_imports=True) + api.convert(fn, platforms=None, show_imports=True) output, error = capfd.readouterr() assert "No imports found." in output