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

Kent Johnson kent37 at tds.net
Sat Apr 1 21:51:33 CEST 2006


Don Taylor wrote:
> Hi:
> 
> I am trying to use Doctest and am having trouble using the ellipsis 
> feature when trying to match an object reference.

What version of Python are you using? The ELLIPSIS comment was added in 
Python 2.4.

Kent

> 
> 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.
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 




More information about the Tutor mailing list