El buscador de profesionales a domicilio

Archive for the ‘pyDoubles’ Category



24
Oct

pyDoubles 1.4 released

Thanks to Nestor Salceda, now pyDoubles do not raise errors on assertion failures, but just fails :-) . Subtle difference but an important one. The other change is a new method alias, suggested by an user:

mock.assert_that_is_satisfied()

is now also:

mock.assert_expectations()

Both methods are the same, just use whichever you fancy.

Thanks also to David Villa for some fine tuning and for packaging pyDoubles for Debian.

Thanks for your feedback, which makes this releases happen :-)

19
Jul

pyDoubles 1.3 released

What's new in pyDoubles 1.3?

  1. times statement is also available in spies, not only mocks
  2. stubs ignoring arguments can live together with stubs defined with arguments
  3. a new matcher: obj_with_fields

1: This sintax is now possible:

 
assert_that_method(spy_obj.some_method).was_called().times(2)
or
assert_that_method(spy_obj.some_method).was_called(
     ).with_args(SOME_VALUE).times(2)
 

2: The most precise matching condition will be used:

 
when(spy_obj.some_method).then_return(SOME_VALUE)
when(spy_obj.some_method).with_args(10
    ).then_return(OTHER_VALUE)
 

The two lines above inside a test would mean the objet will return OTHER_VALUE when the input parameter will be 10 and SOME_VALUE in any other case. In previous releases, it would return SOME_VALUE always because stubs ignoring arguments use to override any other stub definition.

3: obj_with_fields matcher:

 
assert_that_method(spy_obj.some_method).was_called(
    ).with_args(obj_with_fields({'id': 20, 'name': 'Carlos'}))
 

Which means the object passed in as a parameter, should have fields id and name with those values.

1
Jul

pyDoubles 1.1 released

There you go another version of the pyDoubles framework, mock objects for Python and more ;-)

What's new in this release?
Two minor bugfixes. You can see test cases and fixes here and here.
If you want to assert that a given object was passed in as a parameter, as exposed in this test, you have to declare the special methods "__eq__" (equals) and "__ne__" (not equals) in your objects. They are invoked when the framework asserts that the objects are the same. Otherwise, pyDoubles will see they are different instances of the object and will fail on the assertion.

On the other hand there are two new statements:

Celadon theme by the Themes Boutique
teeth bleaching
baldness treatment