[Python-ideas] where statement in Pyret

Tarek Ziadé tarek at ziade.org
Mon Nov 11 09:58:06 CET 2013


Le 11/10/13 10:57 PM, Nick Coghlan a écrit :
>
>
> On 11 Nov 2013 02:12, "Antoine Pitrou" <solipsis at pitrou.net
> <mailto:solipsis at pitrou.net>> wrote:
> >
> > Le 10/11/2013 15:48, Nick Coghlan a écrit :
> >
> >> It would make more sense to just bake py.test style rich assertions
> >> into the language in some way and let people write:
> >>
> >>      def sum(iterable):
> >>          # implementation of sum
> >>
> >>      assert sum([]) == 0
> >>      assert sum([1, 2, 3]) == 6
> >
> >
> > This has the same problem as doctests: it works well for trivial
> tests like the above, but will be difficult to scale towards more
> complicated testing.
>
> Yeah, part of my point was actually that module level assertions allow
> this kind of thing today, and there are good reasons people don't do
> it in practice.
>

Interesting... what if we could mark a block of tests like this :

def sum(iterable):
   # implementation of sum
  
asserts:
   assert sum([]) == 0
   assert sum([1, 2, 3]) == 6   
   ...
   ..more complicated testing here...



Cheers
Tarek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131111/930bf4fe/attachment.html>


More information about the Python-ideas mailing list