<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>twisted &amp;mdash; alan</title>
    <link>https://www.franzoni.eu/alan/tag:twisted</link>
    <description>Alan&#39;s musings</description>
    <language>en</language>
    <pubDate>Tue, 17 Nov 2026 00:40:56 +0000</pubDate>
    <item>
      <title>Unit testing with Twisted: testing protocols</title>
      <link>https://www.franzoni.eu/alan/unit-testing-with-twisted-testing-protocols</link>
      <description>&lt;![CDATA[I had some hard time when testing a href=&#34;http://twistedmatrix.com/trac/&#34;Twisted/a protocols. Although they should be decoupled from factories, most examples I could find, including those from the a href=&#34;http://twistedmatrix.com/trac/browser/trunk/doc/core/howto/trial.xhtml?format=raw&#34;official doc/a, were just too noisy and suggested using a factory.br /br /I don&#39;t like that approach - I should not be forced to use a factory - that creates an unnecessary coupling - let&#39;s just pretend a factory existed and creates a connections, that&#39;s all our protocol should need.br /br /Of course sometimes a protocol is bound to a very specific factory since it needs to invoke methods on it for non protocol-specific data (remember, there&#39;s just one factory, while there&#39;s one protocol per connection). I don&#39;t like that behaviour, since it creates an unnecessary coupling and makes factories huge and not cohesive, and I think protocols should just be injected whatever peers they need during the a href=&#34;http://twistedmatrix.com/documents/current/api/twisted.internet.protocol.Factory.html#buildProtocol&#34;buildProtocol()/a invocation - but I&#39;ll talk about that in another post. In the meantime, I reccommend just creating a mock factory and setting it manually on the protocol.br /br /So, here it is the solution I baked:br /br /script src=&#34;https://gist.github.com/942093.js&#34; /scriptbr /br /What do you think about this solution?&#xA;&#xA;#Ollivander #python #twisted #testing&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>I had some hard time when testing <a href="http://twistedmatrix.com/trac/" rel="nofollow">Twisted</a> protocols. Although they should be decoupled from factories, most examples I could find, including those from the <a href="http://twistedmatrix.com/trac/browser/trunk/doc/core/howto/trial.xhtml?format=raw" rel="nofollow">official doc</a>, were just too noisy and suggested using a factory.<br/><br/>I don&#39;t like that approach – I should not be forced to use a factory – that creates an unnecessary coupling – let&#39;s just pretend a factory existed and creates a connections, that&#39;s all our protocol should need.<br/><br/>Of course sometimes a protocol is bound to a very specific factory since it needs to invoke methods on it for non protocol-specific data (remember, there&#39;s just one factory, while there&#39;s one protocol per connection). I don&#39;t like that behaviour, since it creates an unnecessary coupling and makes factories huge and not cohesive, and I think protocols should just be injected whatever peers they need during the <a href="http://twistedmatrix.com/documents/current/api/twisted.internet.protocol.Factory.html#buildProtocol" rel="nofollow">buildProtocol()</a> invocation – but I&#39;ll talk about that in another post. In the meantime, I reccommend just creating a mock factory and setting it manually on the protocol.<br/><br/>So, here it is the solution I baked:<br/><br/><br/><br/>What do you think about this solution?</p>

<p><a href="/alan/tag:Ollivander" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Ollivander</span></a> <a href="/alan/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a> <a href="/alan/tag:twisted" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">twisted</span></a> <a href="/alan/tag:testing" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">testing</span></a></p>
]]></content:encoded>
      <guid>https://www.franzoni.eu/alan/unit-testing-with-twisted-testing-protocols</guid>
      <pubDate>Sun, 24 Apr 2011 19:03:00 +0000</pubDate>
    </item>
    <item>
      <title>Using trial as test runner with zc.buildout</title>
      <link>https://www.franzoni.eu/alan/using-trial-as-test-runner-with-zc-buildout</link>
      <description>&lt;![CDATA[I&#39;ve found a good way to launch tests using a href=&#34;http://twistedmatrix.com/trac/wiki/TwistedTrial&#34;Twisted Trial/a in a a href=&#34;http://www.buildout.org/&#34;zc.buildout/a enabled project. I was in fear of needing a full-fledged recipe - which I didn&#39;t have the time nor the will to code.br /br /Luckily, a href=&#34;http://pypi.python.org/pypi/zc.recipe.egg&#34;zc.recipe.egg/a seems good enough to satisfy my needs; I wanted a recipe that could launch all unit tests if no parameter was passed, while retaining the ability to choose which specific unit test was launched on command line.br /br /br /Here it is:br /br /script src=&#34;https://gist.github.com/869469.js?file=buildout.cfg&#34;/scriptbr /br /That&#39;s filled in for a href=&#34;http://pydenji.franzoni.eu&#34;pydenji/abr /br /script src=&#34;https://gist.github.com/869469.js?file=example.buildout.cfg&#34;/script&#xA;&#xA;#Ollivander #python #twisted #ZcBuildout&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>I&#39;ve found a good way to launch tests using <a href="http://twistedmatrix.com/trac/wiki/TwistedTrial" rel="nofollow">Twisted Trial</a> in a <a href="http://www.buildout.org/" rel="nofollow">zc.buildout</a> enabled project. I was in fear of needing a full-fledged recipe – which I didn&#39;t have the time nor the will to code.<br/><br/>Luckily, <a href="http://pypi.python.org/pypi/zc.recipe.egg" rel="nofollow">zc.recipe.egg</a> seems good enough to satisfy my needs; I wanted a recipe that could launch all unit tests if no parameter was passed, while retaining the ability to choose which specific unit test was launched on command line.<br/><br/><br/>Here it is:<br/><br/><br/><br/>That&#39;s filled in for <a href="http://pydenji.franzoni.eu" rel="nofollow">pydenji</a><br/><br/></p>

<p><a href="/alan/tag:Ollivander" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Ollivander</span></a> <a href="/alan/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a> <a href="/alan/tag:twisted" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">twisted</span></a> <a href="/alan/tag:ZcBuildout" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ZcBuildout</span></a></p>
]]></content:encoded>
      <guid>https://www.franzoni.eu/alan/using-trial-as-test-runner-with-zc-buildout</guid>
      <pubDate>Mon, 14 Mar 2011 19:55:00 +0000</pubDate>
    </item>
  </channel>
</rss>