Skip to content

Commit

Permalink
Raise correct error (CondaBuildUserError vs SystemExit) in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
beeankha committed Jun 12, 2024
1 parent 3c9516f commit d0a5bdf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions tests/cli/test_main_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Config,
zstd_compression_level_default,
)
from conda_build.exceptions import DependencyNeedsBuildingError
from conda_build.exceptions import CondaBuildUserError, DependencyNeedsBuildingError
from conda_build.os_utils.external import find_executable
from conda_build.utils import get_build_folders, on_win, package_has_file

Expand Down Expand Up @@ -165,7 +165,7 @@ def test_build_long_test_prefix_default_enabled(mocker, testing_workdir):
main_build.execute(args)

args.append("--no-long-test-prefix")
with pytest.raises(SystemExit):
with pytest.raises(CondaBuildUserError):
main_build.execute(args)


Expand Down Expand Up @@ -483,7 +483,7 @@ def test_test_extra_dep(testing_metadata):
main_build.execute(args)

# missing click dep will fail tests
with pytest.raises(SystemExit):
with pytest.raises(CondaBuildUserError):
args = [output, "-t"]
# extra_deps will add it in
main_build.execute(args)
Expand Down
7 changes: 4 additions & 3 deletions tests/test_api_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from conda_build.exceptions import (
BuildScriptException,
CondaBuildException,
CondaBuildUserError,
DependencyNeedsBuildingError,
OverDependingError,
OverLinkingError,
Expand Down Expand Up @@ -279,7 +280,7 @@ def test_no_include_recipe_meta_yaml(testing_metadata, testing_config):
)[0]
assert not package_has_file(output_file, "info/recipe/meta.yaml")

with pytest.raises(SystemExit):
with pytest.raises(CondaBuildUserError):
# we are testing that even with the recipe excluded, we still get the tests in place
output_file = api.build(
os.path.join(metadata_dir, "_no_include_recipe"), config=testing_config
Expand Down Expand Up @@ -545,7 +546,7 @@ def test_skip_existing_url(testing_metadata, testing_workdir, capfd):

def test_failed_tests_exit_build(testing_config):
"""https://github.com/conda/conda-build/issues/1112"""
with pytest.raises(SystemExit, match="TESTS FAILED"):
with pytest.raises(CondaBuildUserError, match="TESTS FAILED"):
api.build(
os.path.join(metadata_dir, "_test_failed_test_exits"), config=testing_config
)
Expand Down Expand Up @@ -1808,7 +1809,7 @@ def test_downstream_tests(testing_config):
upstream = os.path.join(metadata_dir, "_test_downstreams/upstream")
downstream = os.path.join(metadata_dir, "_test_downstreams/downstream")
api.build(downstream, config=testing_config, notest=True)
with pytest.raises(SystemExit):
with pytest.raises(CondaBuildUserError):
api.build(upstream, config=testing_config)


Expand Down
3 changes: 2 additions & 1 deletion tests/test_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pytest

from conda_build import api
from conda_build.exceptions import CondaBuildUserError

from .utils import metadata_dir

Expand Down Expand Up @@ -63,5 +64,5 @@ def test_api_extra_dep(testing_metadata):
api.test(output, config=testing_metadata.config, extra_deps=["click"])

# missing click dep will fail tests
with pytest.raises(SystemExit):
with pytest.raises(CondaBuildUserError):
api.test(output, config=testing_metadata.config)
3 changes: 2 additions & 1 deletion tests/test_subpackages.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from conda.base.context import context

from conda_build import api, utils
from conda_build.exceptions import CondaBuildUserError
from conda_build.metadata import MetaDataTuple
from conda_build.render import finalize_metadata

Expand Down Expand Up @@ -292,7 +293,7 @@ def test_per_output_tests(testing_config):
@pytest.mark.sanity
def test_per_output_tests_script(testing_config):
recipe_dir = os.path.join(subpackage_dir, "_output_test_script")
with pytest.raises(SystemExit):
with pytest.raises(CondaBuildUserError):
api.build(recipe_dir, config=testing_config)


Expand Down

0 comments on commit d0a5bdf

Please sign in to comment.