[Tutor] Doctest, object references and the use of ellipses

Don Taylor nospamformeSVP at gmail.com
Sat Apr 1 21:25:47 CEST 2006


Hi:

I am trying to use Doctest and am having trouble using the ellipsis 
feature when trying to match an object reference.

Here is the code:

     def add_change_listener(self, listener):
         '''

         Returns list of listeners just for testing.
         >>> def mock_listener():
         ...    pass
         >>> model = Model()
         >>> model.add_change_listener(mock_listener) #doctest: +ELLIPSIS
         [<function mock_listener at 0x...>]

         '''

         self.listeners.append(listener)
         return self.listeners

This is what I get back:

Trying:
     model.add_change_listener(mock_listener) #doctest: +ELLIPSIS
Expecting:
     [<function mock_listener at 0x...>]
**********************************************************************
File "D:\ProgrammingProjects\MVCExperiments\src\mvcmodel.py", line 14, 
in __main__.Model.add_change_listener
Failed example:
     model.add_change_listener(mock_listener) #doctest: +ELLIPSIS
Expected:
     [<function mock_listener at 0x...>]
Got:
     [<function mock_listener at 0x00AD9730>]

As far as I can tell from the Doctest documentation this test should 
have passed.

Any help on what I am doing wrong would be much appreciated.

Thanks,

Don.



More information about the Tutor mailing list