.raises() makes fudge ignore .with_args()

Issue #6 resolved
Former user created an issue

raises() seems to be handled too early, moving it back makes it actually do the checks before raising.

{{{

!diff

HG changeset patch

User tv@eagain.net

Date 1244507423 25200

Node ID 7dbe9f0387a9f462d3d3cbb2ee3129cb17489ca2

Parent 2a5595c56b82a832872ec52dc21467ba70921266

Check arguments of callables even if they are about to raise.

diff -r 2a5595c56b82 -r 7dbe9f0387a9 fudge/init.py --- a/fudge/init.py Mon Apr 13 18:19:12 2009 -0500 +++ b/fudge/init.py Mon Jun 08 17:30:23 2009 -0700 @@ -201,9 +201,6 @@ self.call_order.add_actual_call(self) self.call_order.assert_order_met(finalize=False)

  • if self.exception_to_raise is not None:
  • raise self.exception_to_raise
  •  # make sure call count doesn't go over :
     if self.expected_times_called is not None and \
             self.actual_times_called > self.expected_times_called:
    

    @@ -264,6 +261,9 @@ "%s was called with %s keyword arg(s) but expected %s" % ( self, len(kwargs.keys()), self.expected_kwarg_count))

  • if self.exception_to_raise is not None:

  • raise self.exception_to_raise
  •  return return_value
    

    ## hmmm, arg diffing (for Call().call()) needs more thought diff -r 2a5595c56b82 -r 7dbe9f0387a9 fudge/tests/test_fudge.py --- a/fudge/tests/test_fudge.py Mon Apr 13 18:19:12 2009 -0500 +++ b/fudge/tests/test_fudge.py Mon Jun 08 17:30:23 2009 -0700 @@ -148,6 +148,11 @@ def test_with_args_checks_kwargs(self): self.fake.expects('count').with_args('one', two='two') self.fake.count('one') + + @raises(AssertionError) + def test_with_args_checks_kwargs_raises(self): + self.fake.expects('count').with_args('one', two='two').raises(RuntimeError('bork')) + self.fake.count('one')

    @raises(AssertionError) def test_too_many_args(self): @@ -835,4 +840,4 @@ eq_(db.set_id(), None) # extra : eq_(db.get_id(), 1) -
    \ No newline at end of file +
    }}}

Comments (1)

  1. Log in to comment