Welcome to the MiniMockUnit documentation!

class mm_unit.TraceTracker(*args, **kw)

Keeps track of the usage of a MiniMock-ed object, and allows for that usage to be analysed after the fact.

check(want)

Compare expected MiniMock usage with that which we expected.

Parameters:
  • want (string) – the MiniMock output that results from expected usage of mocked objects
Return type:

a True value if the check passed, False otherwise

Example:

>>> from minimock import Mock
>>> tt = TraceTracker()
>>> m = Mock('mock_obj', tracker=tt)
>>> m.some_meth('dummy argument')
>>> tt.check("Called mock_obj.some_meth('dummy argument')")
True
>>> tt.check("Failing expected trace")
False
diff(want)

Compare expected MiniMock usage with that which we expected.

Parameters:
  • want (string) – the MiniMock output that results from expected usage of mocked objects
Return type:

a True value if the check passed, False otherwise

Example:

>>> from minimock import Mock
>>> tt = TraceTracker()
>>> m = Mock('mock_obj', tracker=tt)
>>> m.some_meth('dummy argument')
>>> tt.diff("Dummy string")
"Expected:\n    Dummy string\nGot:\n    Called mock_obj.some_meth('dummy argument')\n"
dump()

Return the MiniMock usage so far.

Example:

>>> from minimock import Mock
>>> tt = TraceTracker()
>>> m = Mock('mock_obj', tracker=tt)
>>> m.some_meth('dummy argument')
>>> tt.dump()
"Called mock_obj.some_meth('dummy argument')\n"
mm_unit.assert_same_trace(tracker, want)

Check the usage of a mm_unit.TraceTracker is as expected.

Parameters:
Raises:

AssertionError if the expected and observed outputs don’t match

Example:

>>> from minimock import Mock
>>> tt = TraceTracker()
>>> m = Mock('mock_obj', tracker=tt)
>>> m.some_meth('dummy argument')
>>> assert_same_trace(tt,
...     "Called mock_obj.some_meth('dummy argument')\n")

Indices and tables