<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 – 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(“should throw bar”):<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </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’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> </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 – 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> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I’ve then got first the basic device, the construction of which is one behaviour I’ve described. Then I have a constructed device, and all other tests apply to that. In those, I’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 setting state, still permit querying state, and permit unlocking – it should not allow the device to be locked again. These hierarchical behaviours share semantics, and also share setup/teardown (before/after) behaviour at different levels. Ie – 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 – but I’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> </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> </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> </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 – I am thinking that a python dsl similar to JS’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'> </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>with describe(“foo”):</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> It(“should throw bar”):</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 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. How is your code better than what you can currently do with unittest?:<br><br> def test_should_throw_bar(self):<br> """foo should throw bar"""<br> with self.assertRaises(BarException):<br> 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'> </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’s mock, that doesn’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'> </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> <o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'> <o:p></o:p></p><div><p class=MsoNormal>On Mon, Mar 26, 2012 at 3:56 AM, <<a href="mailto:Chris.Wesseling@cwi.nl">Chris.Wesseling@cwi.nl</a>> wrote:<o:p></o:p></p><p class=MsoNormal>On 2012-03-24T16:00:06-0500, John MacKenzie wrote:<br>> <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'>> There are failures in both as a demonstration of how this interacts with a<br>> TestRunner. The first one proves mainly that this is just Python; if you<br>> use one of the provided runners you can execute your test files with the<br>> Python interpreter (a big goal after looking at a tool like komira for this<br>> sort of thing). The latter demonstrates that a nose plugin is possible and<br>> probably implies that a py.test plugin is doable to.<o:p></o:p></p></div><p class=MsoNormal>Could you point me to "komira"? Your e-mail turns up as the only<br>relevant hit using my search-fu.<o:p></o:p></p><div><p class=MsoNormal> <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> <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 <o:p></o:p></p></div><div><p class=MsoNormal>significant gain over current testing standards, they fail when the complexity goes beyond <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> <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> <o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal> <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>> Beyond sclara, I'm considering the idea that, more than a testing<br>> framework, I stumbled on an interesting pattern for building generic DSLs<br>> in Python (more on this soon, hopefully).<br>><br>> 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> with test('does not have access to inner setup context') as context:<br> try:<br> context.bar<br> except AttributeError:<br> pass<br><br><br>Will this fail if no AttributeError is thrown?<br><br>And line 45:<br><br> with test('has access to inner setup context') as context:<br> assert context.foo == 'bar'<br><br> with test('has access to outer setup context') as context:<br> assert context.bar == 'foo'<br><br>Shouldn't "inner" and "outer" 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> <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] <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> <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 & 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> <o:p></o:p></p><p class=MsoNormal><o:p> </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>