Date: Thu, 23 Jul 2015 20:00:00 -0400
<p>Visit our <a href="http://pythonpodcast.com?utm_source=rss&utm_medium=rss">site</a> to listen to past episodes, learn more about the show and sign up for our mailing list.</p> <h3>Summary</h3> <p>In this episode we talked to Holger Krekel about the py.test library. We discussed the various styles of testing that it supports, the plugin system and how it compares to the unittest library. We also reviewed some of the challenges around packaging and releasing Python software and our thoughts on some ways that they can be improved.</p> <h3>Brief Introduction</h3> <ul> <li>Welcome to Podcast.__init__ the podcast about Python and the people who make it great</li> <li>Date of recording – July 8th, 2015</li> <li>Hosts Tobias Macey and Chris Patti</li> <li>Follow us on <a href="https://itunes.apple.com/us/podcast/podcast.-init/id981834425?mt=2&uo=6&at=&ct=&utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">iTunes</a>, <a href="http://www.stitcher.com/s?fid=64838&refid=stpr&utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Stitcher</a> or <a href="http://tunein.com/radio/Podcast__init__-p726240/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">TuneIn</a></li> <li>Give us feedback on <a>iTunes</a>, <a href="https://twitter.com/Podcast__init__?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Twitter</a>, <a href="mailto:hosts@podcastinit.com">email</a> or <a href="http://podcastinit.com?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Disqus</a>)</li> <li>We donate our time to you because we love Python and its community. If you would like to return the favor you can send us a <a>donation</a>}. Everything that we don’t spend on producing the show will be donated to the PSF to keep the community alive.</li> <li>Overview – Interview with Holger Krekel about his work on Pytest</li> </ul> <h3>Interview with Holger Krekel</h3> <ul> <li>Introductions <ul> <li>Programming for 25 years</li> <li>Runs a consultancy</li> <li>Been to almost every EuroPyCon and PyCon US</li> </ul> </li> <li>How did you get introduced to Python? – Chris <ul> <li>Wanted to write an HTTP proxy and Java I/O was too confusing. Jython took less than a day to get it working after 2-3 days on it with Java.</li> </ul> </li> <li>What inspired you to create Pytest, and how did the existing unittest framework play into the story? – Chris <ul> <li>Introduced to agile methods through the Zope community</li> <li>Zope used unittest – didn’t like the boiler plate</li> <li>Not in the spirit of Python</li> <li>Only took ~200 lines of code to get a testing tool working</li> <li>Original name was ‘utest’ – 2003</li> <li>Pytest name came in 2004 on <a href="http://pypy.org/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Pypy project</a></li> <li>Huge number of tests on that project (20,000) – distributed test runner – xdist helped solve this.</li> </ul> </li> <li>There are many different styles of testing, such as BDD, unit testing, integration testing, functional testing, what attributes of py.test make it suitable or unsuitable for these different approaches? – Tobias <ul> <li>What are your views on black box testing and how would someone use py.test to implement this approach? – Tobias</li> <li>Pytest’s plugin architecture enables you to hook into the various phases of test execution enabling you to extend Pytest in all kinds of ways beyond the original design.</li> <li>I have been hearing a lot about property based testing which was popularized by the Quickcheck module in Haskell. Does py.test support anything like that? – Tobias</li> <li><a href="https://pypi.python.org/pypi/hypothesis-pytest/0.11.0?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">hypothesis-pytest</a></li> </ul> </li> <li>Do you think the characteristics and nature of the unit testing framework being used have any effect on the number and quality of the tests developers write? – Chris <ul> <li>Developers find writing tests in Pytest to be fun compared to unittest</li> <li>Which will help people write better tests</li> <li>Encourages refactoring</li> </ul> </li> <li>Is there ever a time when you would advice against writing tests? – Tobias <ul> <li>When exploring a problem, writing tests first doesn’t make sense</li> <li>When getting feedback on a potential approach, writing tests first can be a waste of time</li> </ul> </li> <li>What are some signs that you watch out for when writing tests that tell you that a particular feature needs to be refactored? – Tobias <ul> <li>When the test code is fragile it should be refactored</li> <li>Requires experience to really understand when to refactor</li> <li>When it’s not fun anymore or the tests are repetitive</li> </ul> </li> <li>For someone who is converting their existing unit tests from UnitTest/Nose style to use py.test in an idiomatic manner, what are some of the biggest differences to be aware of? – Tobias <ul> <li>Generator/yield based testing should move to property based testing</li> <li>If py.test can’t run a UnitTest/Nose style test it is considered a bug and gets fixed</li> </ul> </li> <li>Has the strict backwards compatibility policy presented any interesting technical challenges thus far? – Chris <ul> <li>Yes it definitely makes more work</li> <li>However breaking the API in a large project like this will cause too many problems for users</li> </ul> </li> <li>py.test supports execution of tests written with other frameworks, how much ongoing maintenance does this feature require as changes are made to the other implementations? – Tobias</li> <li>The web page says that Pytest is designed to work with domain specific and non Python tests, and in fact a coworker is using it to test a node.js project – how did Pytest’s design enable this? – Chris <ul> <li>Pytest uses a collection tree model to represent your project <ul> <li>This is not Python specific</li> <li>All classes and functions are just mapped into this tree, not directly on the Python function</li> </ul> </li> <li>There are few Python specific hooks for fixtures etc.</li> <li>People have written plugins so they can express their tests in YAML, Microsoft Excel</li> <li>Tests are represented as items</li> <li>All plugins are written in Python</li> </ul> </li> <li>What are some of the most interesting applications of py.test that you have seen? – Tobias <ul> <li>Plugins!</li> <li>Pytest-BDD</li> <li>Pytest-C++</li> <li>Pytest-sugar</li> <li><a href="http://pytest.org/latest/plugins_index/index.html?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Py.test plugin list</a></li> </ul> </li> <li>Speaking about adoption, do you have any sense of the relative adoption of Pytest versus unitest or other tools? – Tobias <ul> <li>Very hard to actually know</li> <li>Download numbers are not a clear indicator due to robots, CI systems, etc.</li> <li>Quantifying market share is hard to do</li> <li>Popularity is not a useful heuristic in determining a good fot for technology adoption <ul> <li>But popularity is an indicator for the level of support you might receive</li> <li>Tech can be popular but very poorly maintained</li> </ul> </li> </ul> </li> <li>Are there any features of py.test that would make it suitable for use with configuration management tools and infrastructure testing? – Tobias <ul> <li>Example driven testing</li> <li>Run py.test from a blackbox approach</li> <li>Largest benefit would be from having one testing tool used across the organization</li> </ul> </li> <li>Where do you see Pytest and more generally test frameworks headed in the future? – Chris <ul> <li>No big changes for Pytest – lots of incremental things</li> <li>Plugins will add functionality</li> <li>Holger is also the author of <a href="https://bitbucket.org/hpk42/tox?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Tox</a></li> <li>Integration testing and testing in more complex environments are a direction that test management tools will likely go</li> <li>Tools like Jenkins can be a real headache in trying to have a good testing story for your company</li> <li><a href="https://devpi.net/hpk/dev/devpi-server/2.2.0/+toxresults/devpi-server-2.2.0.tar.gz?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">https://devpi.net/hpk/dev/devpi-server/2.2.0/+toxresults/devpi-server-2.2.0.tar.gz?utmsource=rss&utmmedium=rss</a></li> </ul> </li> <li>Any questions we didn’t ask? <ul> <li>Pytest is a very healthy project! There are 10 regular contributors – this is exceptional among OSS projects</li> </ul> </li> </ul> <h3>Picks</h3> <ul> <li>Tobias <ul> <li><a href="http://python-future.org?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">python-future</a></li> <li><a href="http://pythonhosted.org/six/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">six</a></li> <li><a href="http://www.imdb.com/title/tt1023114/?ref_=nv_sr_1&utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">The Way Back</a></li> <li><a href="http://amzn.to/1J42d0M?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Rosewill BK-500A</a>} or <a>BK-500i</a></li> <li><a href="https://github.com/naiquevin/pipdeptree?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">pipdeptree</a></li> <li><a href="https://github.com/steder/pundler?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">pundler</a></li> </ul> </li> <li>Chris <ul> <li><a href="https://untappd.com/b/crop-bistro-and-brewery-bavarian-weizen/330954?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Crop Bavarian Weizen</a></li> <li><a href="https://en.wikipedia.org/wiki/Pannekoek?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Dutch Pancakes</a></li> <li><a href="http://comicsalliance.com/prophet-the-barbarian-space-opera-you-should-already-be-readi/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Prophet</a></li> </ul> </li> <li>Holger <ul> <li><a href="http://amzn.to/1fnhVgt?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">The Utopia of Rules</a></li> <li><a href="http://ipfs.io/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">IPFS.io</a> – The interplanetary file system</li> <li><a href="https://www.youtube.com/watch?v=oCZMoY3q2uM&utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">A New Way to Look at Networking</a></li> </ul> </li> </ul> <h3>Keep In Touch</h3> <ul> <li><a href="https://twitter.com/hpk42?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Twitter</a></li> <li><a href="http://holgerkrekel.net?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Blog</a></li> </ul> <p>The intro and outro music is from Requiem for a Fish <a href="http://freemusicarchive.org/music/The_Freak_Fandango_Orchestra/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">The Freak Fandango Orchestra</a> / <a href="http://creativecommons.org/licenses/by-sa/3.0/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">CC BY-SA</a><img alt="" height="0" src="https://analytics.boundlessnotions.com/piwik.php?idsite=1&rec=1&url=https%3A%2F%2Fwww.pythonpodcast.com%2Fepisode-16-holger-krekel-on-py-test%2F&action_name=Holger+Krekel+on+Py.Test+-+Episode+16&urlref=https%3A%2F%2Fwww.pythonpodcast.com%2Ffeed%2F&utm_source=rss&utm_medium=rss" style="border: 0; width: 0; height: 0;" width="0" /></p>