Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
singiamtel authored and ktf committed Nov 5, 2024
1 parent 4f0cf47 commit 47c511f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/test_packagelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,14 @@ def test_replacement_recipe_given(self):
@mock.patch("alibuild_helpers.utilities.dieOnError")
def test_missing_replacement_spec(self, mock_dieOnError):
"""Check an error is thrown when the replacement spec is not found."""
specs, systemPkgs, ownPkgs, failedReqs, validDefaults = \
getPackageListWithDefaults(["missing-spec"])
mock_dieOnError.assert_any_call(True, "Could not find named replacement "
"spec for missing-spec: missing_tag")
assert_msg = "Could not find named replacement spec for missing-spec: missing_tag"
# Change the behaviour from sys.exit to a regular exception. Without it
# we don't stop execution properly and other asserts might trigger
mock_dieOnError.side_effect = lambda cond, _: (_ for _ in ()).throw(Exception("dieOnError called")) if cond else None
with self.assertRaises(Exception, msg=assert_msg) as context:
specs, systemPkgs, ownPkgs, failedReqs, validDefaults = \
getPackageListWithDefaults(["missing-spec"])
self.assertEqual(str(context.exception), "dieOnError called", msg=assert_msg)


@mock.patch("alibuild_helpers.utilities.getRecipeReader", new=MockReader)
Expand Down

0 comments on commit 47c511f

Please # to comment.