Skip to content

Commit

Permalink
TST Use assert_raises instead of more complex constructs
Browse files Browse the repository at this point in the history
  • Loading branch information
rth committed Sep 13, 2018
1 parent a600921 commit 7e6ee58
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
5 changes: 1 addition & 4 deletions scipy/optimize/tests/test_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,11 +1007,8 @@ def test_fminbound(self):
assert_raises(ValueError, optimize.fminbound, self.fun, 5, 1)

def test_fminbound_scalar(self):
try:
with pytest.raises(ValueError, match='.*must be scalar.*'):
optimize.fminbound(self.fun, np.zeros((1, 2)), 1)
self.fail("exception not raised")
except ValueError as e:
assert_('must be scalar' in str(e))

x = optimize.fminbound(self.fun, 1, np.array(5))
assert_allclose(x, self.solution, atol=1e-6)
Expand Down
7 changes: 1 addition & 6 deletions scipy/stats/tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3243,12 +3243,7 @@ def test_signature_inspection_2args(self):

def test_signature_inspection_2args_incorrect_shapes(self):
# both _pdf and _cdf defined, but shapes are inconsistent: raises
try:
_distr3_gen(name='dummy')
except TypeError:
pass
else:
raise AssertionError('TypeError not raised.')
assert_raises(TypeError, _distr3_gen, **dict(name='dummy'))

def test_defaults_raise(self):
# default arguments should raise
Expand Down

0 comments on commit 7e6ee58

Please sign in to comment.