<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        color:black;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";
        color:black;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=EN-GB link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hmm &#8211; that should have been <o:p></o:p></span></p><p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>with it(&#8220;should throw bar&#8221;):<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>And the semicolon crept in because I&#8217;ve been switching languages a fair bit today.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>But I see your point &#8211; for the most part, I have been using unittest. I do like the hierarchy though as it represents a hierarchy of behaviour and state. Consider an object representing a hardware resource. It can be constructed, then locked/unlocked (allowing other users of it), and then other state, when locked can be set.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I&#8217;ve then got first the basic device, the construction of which is one behaviour I&#8217;ve described. Then I have a constructed device, and all other tests apply to that. In those, I&#8217;ve the Locked behaviour, and the unlocked behaviour. The unlocked behaviour has the test for locking a device, and tests to ensure operations like unlocked, setting its state throw exceptions, while querying the state is permitted. The locked behaviour should permit&nbsp; setting state, still permit querying state, and permit unlocking &#8211; it should not allow the device to be locked again. &nbsp;These hierarchical behaviours share semantics, and also share setup/teardown (before/after) behaviour at different levels. Ie &#8211; setup for any mocks needed to construct the thing, setup a constructed object, and setup a locked object. Nesting could give a more expressive means of combination, thus meaning less duplication. I realise this could be done with helpers of other kinds &#8211; but I&#8217;ve seen in both a very brief and very clear test written this way.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Danny<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> Ned Batchelder [mailto:ned@nedbatchelder.com] <br><b>Sent:</b> 26 March 2012 13:48<br><b>To:</b> Staple, Danny (BSKYB)<br><b>Cc:</b> 'Alfredo Deza'; Chris.Wesseling@cwi.nl; John MacKenzie; testing-in-python@lists.idyll.org<br><b>Subject:</b> Re: [TIP] Sclara is a Python testing DSL<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>On 3/26/2012 8:28 AM, Staple, Danny (BSKYB) wrote: <o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hmm &#8211; I am thinking that a python dsl similar to JS&#8217;s Jasmine with matchers would be doable.</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>with describe(&#8220;foo&#8221;):</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp; It(&#8220;should throw bar&#8221;):</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp; &nbsp;expect( lambda : foo.doStuff()).toRaise(BarException);</span><o:p></o:p></p><p class=MsoNormal>I've never seen the value in ladling English all over my test cases.&nbsp; How is your code better than what you can currently do with unittest?:<br><br>&nbsp;&nbsp;&nbsp; def test_should_throw_bar(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;foo should throw bar&quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; with self.assertRaises(BarException):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foo.doStuff()<br><br>Not to mention, the snippet you presented isn't valid Python, yet involves a lambda...<br><br>--Ned.<br><br><br><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>There definitely are many python test things other than doctest and unittest (Freshen, Lettuce, PySpec, spec plugin for nose, should-dsl for some). The trick to acceptance is compatibility probably, make sure that there is a nose plugin, that it works with Micheal Foord&#8217;s mock, that doesn&#8217;t do such strange magic that it taints the global namespace and makes stuff behave incorrectly. </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> <a href="mailto:testing-in-python-bounces@lists.idyll.org">testing-in-python-bounces@lists.idyll.org</a> [<a href="mailto:testing-in-python-bounces@lists.idyll.org">mailto:testing-in-python-bounces@lists.idyll.org</a>] <b>On Behalf Of </b>Alfredo Deza<br><b>Sent:</b> 26 March 2012 12:08<br><b>To:</b> <a href="mailto:Chris.Wesseling@cwi.nl">Chris.Wesseling@cwi.nl</a><br><b>Cc:</b> John MacKenzie; <a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br><b>Subject:</b> Re: [TIP] Sclara is a Python testing DSL</span><o:p></o:p></p><p class=MsoNormal>&nbsp;<o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>&nbsp;<o:p></o:p></p><div><p class=MsoNormal>On Mon, Mar 26, 2012 at 3:56 AM, &lt;<a href="mailto:Chris.Wesseling@cwi.nl">Chris.Wesseling@cwi.nl</a>&gt; wrote:<o:p></o:p></p><p class=MsoNormal>On 2012-03-24T16:00:06-0500, John MacKenzie wrote:<br>&gt; <a href="http://github.com/198d/sclara" target="_blank">http://github.com/198d/sclara</a><br>[...]<o:p></o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'>&gt; There are failures in both as a demonstration of how this interacts with a<br>&gt; TestRunner. The first one proves mainly that this is just Python; if you<br>&gt; use one of the provided runners you can execute your test files with the<br>&gt; Python interpreter (a big goal after looking at a tool like komira for this<br>&gt; sort of thing). The latter demonstrates that a nose plugin is possible and<br>&gt; probably implies that a py.test plugin is doable to.<o:p></o:p></p></div><p class=MsoNormal>Could you point me to &quot;komira&quot;? Your e-mail turns up as the only<br>relevant hit using my search-fu.<o:p></o:p></p><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>Konira is a Testing DSL framework [0] that I started working on about a year and a half ago. It<o:p></o:p></p></div><div><p class=MsoNormal>is not valid Python (hence the DSL connotation) but it is translated to it when tests are run<o:p></o:p></p></div><div><p class=MsoNormal>via de included Test Runner or with the py.test [1] plugin for it.<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>The problem that I see these solutions (including Konira) bring to the table is that they all try to<o:p></o:p></p></div><div><p class=MsoNormal>create a flexible, descriptive and terse domain for writing tests, and while some of them have a&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>significant gain over current testing standards, they&nbsp;fail when the complexity goes beyond&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>asserting something that has a nice description.<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>It might be heretic to raise this in a testing list for Python, but I also believe that the Python community<o:p></o:p></p></div><div><p class=MsoNormal>is not as pro-innovation in the testing environment as other communities are, which is detrimental to the fact<o:p></o:p></p></div><div><p class=MsoNormal>that there are a few people who don't like the standard testing framework and are looking forwards to an<o:p></o:p></p></div><div><p class=MsoNormal>alternative.<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>&gt; Beyond sclara, I'm considering the idea that, more than a testing<br>&gt; framework, I stumbled on an interesting pattern for building generic DSLs<br>&gt; in Python (more on this soon, hopefully).<br>&gt;<br>&gt; Thoughts?<o:p></o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'>I started reading the tests, to see if the DSL provides the clarity we need in<br>this domain:<br><br>examples/test_sclara.py line 14:<br><br>&nbsp; &nbsp;with test('does not have access to inner setup context') as context:<br>&nbsp; &nbsp; &nbsp; &nbsp;try:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;context.bar<br>&nbsp; &nbsp; &nbsp; &nbsp;except AttributeError:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pass<br><br><br>Will this fail if no AttributeError is thrown?<br><br>And line 45:<br><br>&nbsp; &nbsp;with test('has access to inner setup context') as context:<br>&nbsp; &nbsp; &nbsp; &nbsp;assert context.foo == 'bar'<br><br>&nbsp; &nbsp;with test('has access to outer setup context') as context:<br>&nbsp; &nbsp; &nbsp; &nbsp;assert context.bar == 'foo'<br><br>Shouldn't &quot;inner&quot; and &quot;outer&quot; be swapped here?<br>The outer setup adds foo and baz attributes.<br>The inner setup adds the bar attribute to the context and changes the baz value.<br><br><br>What I see as a pitfall for users with this idiom, is that it might invite to<br>breaking isolation.<br><br>Interesting, though.<o:p></o:p></p></blockquote><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>[0] <a href="http://konira.cafepais.com/docs/index.html">http://konira.cafepais.com/docs/index.html</a><o:p></o:p></p></div><div><p class=MsoNormal>[1]&nbsp;<a href="http://pypi.python.org/pypi/pytest-konira">http://pypi.python.org/pypi/pytest-konira</a><o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><p class=MsoNormal style='margin-bottom:12.0pt'><span class=hoenzb><span style='color:#888888'>--</span></span><span style='color:#888888'><br><span class=hoenzb>Chris Wesseling</span><br><span class=hoenzb>Centrum Wiskunde &amp; Informatica (CWI)</span><br><span class=hoenzb><a href="https://www.cwi.nl/people/ccw" target="_blank">https://www.cwi.nl/people/ccw</a></span><br></span><br>_______________________________________________<br>testing-in-python mailing list<br><a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br><a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><o:p></o:p></p></blockquote></div><p class=MsoNormal>&nbsp;<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><div class=MsoNormal align=center style='text-align:center'><hr size=2 width="100%" align=center></div><p class=MsoNormal><span style='font-size:7.5pt;font-family:"Arial","sans-serif";color:gray'><br>**************************************************************************************<br>This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the <a href="mailto:postmaster@nds.com">postmaster@nds.com</a> and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.<br><br>NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00<br>**************************************************************************************<br></span><br><br><br><o:p></o:p></p><pre>_______________________________________________<o:p></o:p></pre><pre>testing-in-python mailing list<o:p></o:p></pre><pre><a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><o:p></o:p></pre><pre><a href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/listinfo/testing-in-python</a><o:p></o:p></pre></div></body></html>