Skip to content

Conversation

@tcassou
Copy link
Owner

@tcassou tcassou commented Sep 25, 2025

Motivation & Context

In 1.x.x the package had 2 major limitations:

  1. it was limited to mocking class methods only (all forms of class methods);
  2. it was not robust to collisions between class/method names for mocks defined by referencing class/method names.

This major upgrade addresses all of this and brings a few extra improvements.

Description

  • mocks of standalone functions are now possible, and work in the exact same way as class method mocks
  • this is possible thanks to a simpler, unified syntax for mock statements: Expect(function_or_method).to_receive(*args, **kwargs).and_return(something)
  • mock statement cannot reference class/method/function names anymore, and have to reference the object themselves
  • the code is deeply refactored to rely on more specialized and thinner objects, with a clearer separation of concerns
  • a lot more tests are added to cover all possible corner cases and sequences of tests

Breaking Changes

Yes: with 2.x.x, Expect statements relying on class/method names will break.

Checklist

  • Changes are tested
  • Pre-release packages work as expected
  • Docs are up to date (README.md, docstrings, etc)

@tcassou tcassou merged commit 7c3a020 into master Sep 26, 2025
3 checks passed
@tcassou tcassou deleted the tc/major branch September 26, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant