<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>posts on PythonTest</title>
    <link>https://pythontest.com/posts/</link>
    <description>Recent content in posts on PythonTest</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 11 Nov 2025 07:24:00 +0800</lastBuildDate>
    <atom:link href="https://pythontest.com/posts/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Explore Python dependencies with `pipdeptree` and `uv pip tree`</title>
      <link>https://pythontest.com/pipdeptree-uv-pip-tree/</link>
      <pubDate>Tue, 11 Nov 2025 07:24:00 +0800</pubDate>
      <guid>https://pythontest.com/pipdeptree-uv-pip-tree/</guid>
      <description>&lt;p&gt;Sometimes you just want to know about your dependencies, and their dependencies.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve been using &lt;code&gt;pipdeptree&lt;/code&gt; for a while, but recently switched to &lt;code&gt;uv pip tree&lt;/code&gt;.&lt;br&gt;&#xA;Let&amp;rsquo;s take a look at both tools.&lt;/p&gt;&#xA;&lt;h2 id=&#34;pipdeptree&#34;&gt;pipdeptree&lt;/h2&gt;&#xA;&lt;p&gt;&lt;code&gt;pipdeptree&lt;/code&gt; is pip installable, but I don&amp;rsquo;t want &lt;code&gt;pipdeptree&lt;/code&gt; itself to be reported alongside everything else installed, so I usually install it outside of a project. We can use it system wide by:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Installing with &lt;code&gt;uv tool install pipdeptree&lt;/code&gt;.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Then running with &lt;code&gt;pipdeptree --python auto&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Running without installing with &lt;code&gt;uvx pipdeptree --python auto&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;usage&#34;&gt;usage&lt;/h3&gt;&#xA;&lt;p&gt;The &lt;code&gt;--python auto&lt;/code&gt; tells &lt;code&gt;pipdeptree&lt;/code&gt; to look at the current environment.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Announcing the Lean TDD book</title>
      <link>https://pythontest.com/announcing-lean-tdd/</link>
      <pubDate>Sun, 02 Nov 2025 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/announcing-lean-tdd/</guid>
      <description>&lt;p&gt;There are many great ideas that I&amp;rsquo;ve gotten from TDD, Lean, Pragmatic, and more.&#xA;For the past few years, I&amp;rsquo;ve really wanted to write a book about TDD, with an emphasis on using Lean teachings to cut out all the waste, and then grow TDD into more of a project wide process.&lt;/p&gt;&#xA;&lt;p&gt;To motivate myself to just get it done finally, I&amp;rsquo;ve started.&#xA;And I&amp;rsquo;m using a holistic project wide process.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Polite lazy imports for Python package maintainers</title>
      <link>https://pythontest.com/polite-lazy-imports-python-packages/</link>
      <pubDate>Sun, 26 Oct 2025 23:13:00 +0800</pubDate>
      <guid>https://pythontest.com/polite-lazy-imports-python-packages/</guid>
      <description>&lt;p&gt;If you are a maintainer of a Python package, it&amp;rsquo;s nice if you pay attention to the time it takes to import your package.&lt;/p&gt;&#xA;&lt;p&gt;Further, if you&amp;rsquo;ve got a Python package with multiple components where it&amp;rsquo;s probable that many users will only use part of the package, then it&amp;rsquo;s super nice if you set up your  &lt;code&gt;__init__.py&lt;/code&gt; files for lazy importing.&lt;/p&gt;&#xA;&lt;h2 id=&#34;previously---lazy-importing-other-packages&#34;&gt;Previously - lazy importing other packages&lt;/h2&gt;&#xA;&lt;p&gt;In &lt;a href=&#34;https://pythontest.com/python-lazy-imports-now&#34;&gt;Python lazy imports you can use today&lt;/a&gt;, I discussed:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Python lazy imports you can use today</title>
      <link>https://pythontest.com/python-lazy-imports-now/</link>
      <pubDate>Mon, 13 Oct 2025 19:00:00 +0800</pubDate>
      <guid>https://pythontest.com/python-lazy-imports-now/</guid>
      <description>&lt;p&gt;There&amp;rsquo;s a proposal, &lt;a href=&#34;https://peps.python.org/pep-0810/&#34;&gt;PEP 810 – Explicit lazy imports&lt;/a&gt; for Python to natively support lazy importing starting in Python 3.15.&lt;/p&gt;&#xA;&lt;p&gt;However, it has not been accepted yet, and even if it is accepted, 3.15 is a year away.&#xA;What do we do now?&lt;/p&gt;&#xA;&lt;p&gt;The techniques covered in this post that allow you to use lazy importing NOW with Python 3.13, Python 3.12, &amp;hellip;, really every version of Python.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s look at a small code example that imports something.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Installing Python 3.14 on Mac or Windows</title>
      <link>https://pythontest.com/python/installing-python-3-14/</link>
      <pubDate>Fri, 10 Oct 2025 20:14:00 +0800</pubDate>
      <guid>https://pythontest.com/python/installing-python-3-14/</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;The easiest way to install Python 3.14 (or 3.13, 3.12, 3.11, 3.10, 3.10, &amp;hellip;)&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I originally wrote this post in 2022 for Python 3.11.&lt;br&gt;&#xA;From 2022 through 2024, I remained of the belief that installing from python.org was the best option for most people.&lt;/p&gt;&#xA;&lt;p&gt;However, 2025 changed that for me, with &lt;code&gt;uv&lt;/code&gt; and &lt;code&gt;uv python&lt;/code&gt; supporting the installation of Python versions. It&amp;rsquo;s a really pleasant and clean way to keep Python versions up to date and install new versions.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Testing against Python 3.14</title>
      <link>https://pythontest.com/testing-with-python-3-14/</link>
      <pubDate>Fri, 10 Oct 2025 16:10:00 +0800</pubDate>
      <guid>https://pythontest.com/testing-with-python-3-14/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://docs.python.org/3.14/whatsnew/3.14.html#what-s-new-in-python-3-14&#34;&gt;Python 3.14&lt;/a&gt; is here.&lt;/p&gt;&#xA;&lt;p&gt;If you haven&amp;rsquo;t done so, it&amp;rsquo;s time to update your projects to test against 3.14.&lt;/p&gt;&#xA;&lt;p&gt;The following procedure is what I&amp;rsquo;m following for a handful of projects. Your process of course may be different if you use different tools.&lt;/p&gt;&#xA;&lt;p&gt;Honestly, I&amp;rsquo;m partly writing this down so I don&amp;rsquo;t have to remember it all in a year when 3.15 rolls around.&lt;/p&gt;&#xA;&lt;h2 id=&#34;installing-python-314&#34;&gt;Installing Python 3.14&lt;/h2&gt;&#xA;&lt;h3 id=&#34;installing-with-uv&#34;&gt;Installing with uv&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;uv self update&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;uv python install 3.14&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;While it&amp;rsquo;s true that creating a virtual environment with &lt;code&gt;uv venv .venv --python 3.14&lt;/code&gt; will install 3.14 if it isn&amp;rsquo;t already there, you still gotta run &lt;code&gt;uv self update&lt;/code&gt;. So I just usually install it while I&amp;rsquo;m at it.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest-check 2.6.0 release</title>
      <link>https://pythontest.com/pytest-check-2-6-0/</link>
      <pubDate>Mon, 06 Oct 2025 21:30:00 +0800</pubDate>
      <guid>https://pythontest.com/pytest-check-2-6-0/</guid>
      <description>&lt;p&gt;There&amp;rsquo;s a new release of &lt;a href=&#34;https://github.com/okken/pytest-check&#34;&gt;pytest-check&lt;/a&gt;. Version 2.6.0.&lt;/p&gt;&#xA;&lt;p&gt;This is a cool contribution from the community.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-problem&#34;&gt;The problem&lt;/h2&gt;&#xA;&lt;p&gt;In July, &lt;a href=&#34;https://github.com/bluenote10&#34;&gt;bluenote10&lt;/a&gt; reported that &lt;code&gt;check.raises()&lt;/code&gt; doesn&amp;rsquo;t behave like &lt;code&gt;pytest.raises()&lt;/code&gt; in that the &lt;code&gt;AssertionError&lt;/code&gt; returned from &lt;code&gt;check.raises()&lt;/code&gt; doesn&amp;rsquo;t have a queryable &lt;code&gt;value&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Example of &lt;code&gt;pytest.raises()&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;with&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;pytest&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;raises&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;ne&#34;&gt;Exception&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;do_something&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;assert&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;str&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;value&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;lt;expected error message&amp;gt;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We&amp;rsquo;d like &lt;code&gt;check.raises()&lt;/code&gt; to act similarly:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;with&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;check&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;raises&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;ne&#34;&gt;Exception&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;do_something&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;assert&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;str&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;value&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;lt;expected error message&amp;gt;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But that didn&amp;rsquo;t work prior to 2.6.0. The issue was that the value returned from &lt;code&gt;check.raises()&lt;/code&gt; didn&amp;rsquo;t have any &lt;code&gt;.value&lt;/code&gt; atribute.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Timeline of Selected Software Events</title>
      <link>https://pythontest.com/timeline-selected-software-events/</link>
      <pubDate>Sat, 13 Sep 2025 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/timeline-selected-software-events/</guid>
      <description>&lt;p&gt;There are a lot of events in the history of software development.&#xA;This is a list of dates that have some significance in either the stuff I work with or methodologies.&#xA;I&amp;rsquo;ve compiled this list for my own benefit in thinking about my history and how these things have led to my current software philosophies.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m publishing the list as a &amp;ldquo;what the heck, why not?&amp;rdquo; kinda thing.&#xA;If I&amp;rsquo;ve gotten something wrong, feel free to &lt;a href=&#34;https://pythontest.com/contact&#34;&gt;contact me&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Python People podcast now at pythontest.com/pythonpeople</title>
      <link>https://pythontest.com/python-people-moved/</link>
      <pubDate>Fri, 05 Sep 2025 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/python-people-moved/</guid>
      <description>&lt;p&gt;Like the recent &lt;a href=&#34;https://pythontest.com/test-and-code-archive-up&#34;&gt;archival of Test and Code&lt;/a&gt;, the Python People podcast has also moved. Python People is now at &lt;a href=&#34;https://pythontest.com/pythonpeople&#34;&gt;pythontest.com/pythonpeople&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is it also archived? As in done?&lt;/p&gt;&#xA;&lt;p&gt;I don&amp;rsquo;t think so. I think I might start that up again at some point.&lt;/p&gt;&#xA;&lt;p&gt;But for now, it&amp;rsquo;s on a long-ish term pause.&lt;/p&gt;&#xA;&lt;p&gt;BTW, the RSS feeds for both Python People and Test and Code should be redirected correctly, so you shouldn&amp;rsquo;t have to change anything in your podcast player.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Test and Code Archive is now available</title>
      <link>https://pythontest.com/test-and-code-archive-up/</link>
      <pubDate>Mon, 01 Sep 2025 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/test-and-code-archive-up/</guid>
      <description>&lt;p&gt;I really appreciate all of the positive feedback I&amp;rsquo;ve gotten when I announced that I was stopping the Test &amp;amp; Code podcast.&#xA;I mean, I didn&amp;rsquo;t get any &amp;ldquo;good idea, you that&amp;rsquo;s a terrible show&amp;rdquo; feedback, thankfully.&lt;br&gt;&#xA;But I did get a lot of people saying that I should keep it alive somehow.&lt;/p&gt;&#xA;&lt;p&gt;So, it&amp;rsquo;s now archived here: &lt;a href=&#34;https://pythontest.com/testandcode&#34;&gt;Test and Code Archive&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;That link also includes a link to the xml that you need if you want to plop that into the &amp;ldquo;subscribe via URL&amp;rdquo; box on really any podcast player.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest fixtures nuts and bolts - revisited</title>
      <link>https://pythontest.com/pytest-fixtures-nuts-bolts-revisited/</link>
      <pubDate>Wed, 06 Aug 2025 06:13:00 -0700</pubDate>
      <guid>https://pythontest.com/pytest-fixtures-nuts-bolts-revisited/</guid>
      <description>&lt;p&gt;In 2013/2014 I wrote a 4 part series on pytest fixtures.&lt;br&gt;&#xA;It started out fine-ish. And then by part 4 I crammed way too many concepts into one huge post.&lt;/p&gt;&#xA;&lt;p&gt;Well, I&amp;rsquo;ve recently reviewed all of this, and&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;split the posts into one concept each&lt;/li&gt;&#xA;&lt;li&gt;made sure all of the info was correct for modern versions of Python and pytest&lt;/li&gt;&#xA;&lt;li&gt;reran the examples to make sure the output is correct&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s the new/old series:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Time Machine back to 2012</title>
      <link>https://pythontest.com/time-machine-to-2012/</link>
      <pubDate>Tue, 27 May 2025 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/time-machine-to-2012/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m doing some blog cleanup.&lt;/p&gt;&#xA;&lt;h2 id=&#34;new-look&#34;&gt;New look&lt;/h2&gt;&#xA;&lt;p&gt;I just recently have this shiny new theme for the blog.&lt;br&gt;&#xA;I&amp;rsquo;m really loving the colors, and the ability to shamelessly plug my courses in the right side-bar. (Below the content if you&amp;rsquo;re reading on mobile).&lt;/p&gt;&#xA;&lt;h2 id=&#34;new-analytics&#34;&gt;New analytics&lt;/h2&gt;&#xA;&lt;p&gt;I don&amp;rsquo;t want to track anyone.&lt;/p&gt;&#xA;&lt;p&gt;But I do want to know:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;which posts are popular&lt;/li&gt;&#xA;&lt;li&gt;which not so much&lt;/li&gt;&#xA;&lt;li&gt;what are people 404-ing on&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To that end, I was using Netlify server side analytics.&lt;br&gt;&#xA;It was ok, but also rather restrictive.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Unravelling t-strings with pytest</title>
      <link>https://pythontest.com/unravelling-t-strings-pytest/</link>
      <pubDate>Mon, 26 May 2025 09:22:00 +0800</pubDate>
      <guid>https://pythontest.com/unravelling-t-strings-pytest/</guid>
      <description>&lt;p&gt;Brett Cannon recently released a great article explaining how Python 3.14&amp;rsquo;s new t-strings work.&lt;/p&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s the article: &lt;a href=&#34;https://snarky.ca/unravelling-t-strings/&#34;&gt;Unravelling t-strings&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;He built up the functionality of how t-strings work in a way that you can follow along even if you don&amp;rsquo;t have 3.14.0b1 (where t-strings are instroduced), all the way up to the last example.&lt;/p&gt;&#xA;&lt;p&gt;He walks through&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Evaluating the Python expression&lt;/li&gt;&#xA;&lt;li&gt;Applying specified conversions&lt;/li&gt;&#xA;&lt;li&gt;Applying format specs&lt;/li&gt;&#xA;&lt;li&gt;Using an Interpolation class to hold details of replacement fields&lt;/li&gt;&#xA;&lt;li&gt;Using Template class to hold parsed data&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The end result is very close to an &lt;a href=&#34;https://peps.python.org/pep-0750/#example-implementing-f-strings-with-t-strings&#34;&gt;example used in PEP 750&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Testing some tidbits with pytest</title>
      <link>https://pythontest.com/pytest/testing-tidbits-pytest/</link>
      <pubDate>Mon, 16 Dec 2024 07:00:00 +0800</pubDate>
      <guid>https://pythontest.com/pytest/testing-tidbits-pytest/</guid>
      <description>&lt;p&gt;I noticed a fun post by Ned Batchelder called &lt;a href=&#34;https://nedbatchelder.com/blog/202412/testing_some_tidbits.html&#34;&gt;Testing some tidbits&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The post looks at different ways to see if a string has only 0 or 1 in it.&lt;/p&gt;&#xA;&lt;p&gt;He posted a few ways on Bluesky/Mastodon and got a bunch of replies with more ways. And then wrote a small script to check to see if they worked.&lt;/p&gt;&#xA;&lt;p&gt;It&amp;rsquo;s a fun post, and from it I learned about:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;cleandoc&lt;/code&gt; - a way to strip leading blank space and maintain code block indentation&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;partition&lt;/code&gt; - splitting strings based on a substring&lt;/li&gt;&#xA;&lt;li&gt;Using &lt;code&gt;|&lt;/code&gt; to pass imports to &lt;code&gt;eval()&lt;/code&gt; - I don&amp;rsquo;t use &lt;code&gt;eval&lt;/code&gt; much.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I was a little dissapointed that with a title like &amp;ldquo;Testing some tidbits&amp;rdquo;, Ned didn&amp;rsquo;t use pytest or any other test framework.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Finding the top pytest plugins</title>
      <link>https://pythontest.com/pytest/finding-top-pytest-plugins/</link>
      <pubDate>Sun, 25 Aug 2024 05:00:00 +0800</pubDate>
      <guid>https://pythontest.com/pytest/finding-top-pytest-plugins/</guid>
      <description>&lt;p&gt;What are the top downloaded pytest plugins?&lt;br&gt;&#xA;I want to know this. And I&amp;rsquo;d like the answer updated regularly.&lt;br&gt;&#xA;So today I decided to write a script to do that for me.&lt;/p&gt;&#xA;&lt;h2 id=&#34;grab-data&#34;&gt;Grab data&lt;/h2&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s start with &lt;a href=&#34;https://hugovk.github.io/top-pypi-packages/&#34;&gt;Top PyPI Packages&lt;/a&gt; from &lt;a href=&#34;https://github.com/hugovk/&#34;&gt;Hugo van Kemenade&lt;/a&gt;. This list is &amp;ldquo;A monthly dump of the 8,000 most-downloaded packages from PyPI.&amp;rdquo;&lt;/p&gt;&#xA;&lt;p&gt;Perfect.&lt;/p&gt;&#xA;&lt;h2 id=&#34;parse&#34;&gt;Parse&lt;/h2&gt;&#xA;&lt;p&gt;Now:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Filter for &amp;ldquo;pytest&amp;rdquo; in the package name&lt;/li&gt;&#xA;&lt;li&gt;Remove &amp;ldquo;pytest&amp;rdquo; itself.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I could leave this in for comparison, but it would always be #1.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Renumber.&lt;/li&gt;&#xA;&lt;li&gt;Include a link to the pypi.org package page.&lt;/li&gt;&#xA;&lt;li&gt;Throw it all in a table.&lt;/li&gt;&#xA;&lt;li&gt;Pipe it to a markdown blog page.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;added-on-26-aug&#34;&gt;Added on 26-Aug:&lt;/h3&gt;&#xA;&lt;p&gt;Grab summaries from pypi.org via Warehouse API.&lt;br&gt;&#xA;Thanks Jeff Triplett and Hugo for pointing me in that direction.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest 8 is here</title>
      <link>https://pythontest.com/pytest/pytest-8-is-here/</link>
      <pubDate>Mon, 29 Jan 2024 20:00:00 +0800</pubDate>
      <guid>https://pythontest.com/pytest/pytest-8-is-here/</guid>
      <description>&lt;p&gt;pytest 8.0.0 was released on 17-Jan-2024, and I&amp;rsquo;m pretty excited about it.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m not going to cover all fo the changes, I&amp;rsquo;ll just highlight a few.&lt;br&gt;&#xA;For full set of changes, see the &lt;a href=&#34;https://docs.pytest.org/en/stable/changelog.html&#34;&gt;pytest changelog&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://docs.pytest.org/en/stable/changelog.html#pytest-8-0-0rc1-2023-12-30&#34;&gt;Changes in 8.0.0rc1&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://docs.pytest.org/en/stable/changelog.html#pytest-8-0-0rc2-2024-01-17&#34;&gt;Changes in 8.0.0rc2&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://docs.pytest.org/en/stable/changelog.html#pytest-8-0-0-2024-01-27&#34;&gt;Changes in 8.0.0&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;version-compatibility&#34;&gt;Version Compatibility&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Dropped support for Python 3.7, as it reached EOL last June.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;features-and-improvements&#34;&gt;Features and Improvements&lt;/h2&gt;&#xA;&lt;h3 id=&#34;improved-diffs&#34;&gt;Improved Diffs&lt;/h3&gt;&#xA;&lt;p&gt;Improved diffs that pytest prints when an assertion fails, including:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Testing argparse Applications</title>
      <link>https://pythontest.com/testing-argparse-apps/</link>
      <pubDate>Thu, 16 Nov 2023 07:20:00 -0800</pubDate>
      <guid>https://pythontest.com/testing-argparse-apps/</guid>
      <description>&lt;p&gt;I was asked recently about how to test the argument parsing bit of an application that used &lt;a href=&#34;https://docs.python.org/3/library/argparse.html&#34;&gt;&lt;code&gt;argparse&lt;/code&gt;&lt;/a&gt;. &lt;code&gt;argparse&lt;/code&gt; is a built in Python library for dealing with parsing command line arguments for command line interfaces, CLI&amp;rsquo;s.&lt;/p&gt;&#xA;&lt;p&gt;You know, like &lt;code&gt;git clone &amp;lt;repo address&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;git&lt;/code&gt; is the application.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;repo address&amp;gt;&lt;/code&gt; is a command line argument.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;clone&lt;/code&gt; is a sub-command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Well, that might be a bad example, as I&amp;rsquo;m not going to use subcommands in my example, but lots of this still applies, even if you are using subcommands. Anyway, loads of applications use command line arguments, also sometimes called flags and options.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest slow order</title>
      <link>https://pythontest.com/pytest-slow-order/</link>
      <pubDate>Thu, 02 Nov 2023 14:39:00 -0700</pubDate>
      <guid>https://pythontest.com/pytest-slow-order/</guid>
      <description>&lt;p&gt;I received a question the other day about combining the notion of marking slow tests and ordering them to run the slow tests first.&lt;/p&gt;&#xA;&lt;p&gt;This post describes a bit of background and a solution to the problem.&lt;/p&gt;&#xA;&lt;h2 id=&#34;pytestmarkslow&#34;&gt;@pytest.mark.slow&lt;/h2&gt;&#xA;&lt;p&gt;It&amp;rsquo;s possible to mark slow tests with &lt;code&gt;@pytest.mark.slow&lt;/code&gt; and then either run or skip the slow tests.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To run slow tests: &lt;code&gt;pytest -m slow&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;To skip slow tests: &lt;code&gt;pytest -m &amp;quot;not slow&amp;quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;With the &lt;a href=&#34;https://pypi.org/project/pytest-skip-slow/&#34;&gt;pytest-skip-slow&lt;/a&gt; plugin, you can:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Upgrading to Python 3.12 and my battle with virtualenv cache</title>
      <link>https://pythontest.com/posts/2023/2023-10-02-py312-impimporter/</link>
      <pubDate>Mon, 02 Oct 2023 12:29:07 -0700</pubDate>
      <guid>https://pythontest.com/posts/2023/2023-10-02-py312-impimporter/</guid>
      <description>&lt;p&gt;&lt;em&gt;edited Oct 3, 2023 with a new fix and a new understanding of the problem&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Initial title was &amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Python 3.12 + &amp;quot;AttributeError: module &amp;lsquo;pkgutil&amp;rsquo; has no attribute &amp;lsquo;ImpImporter&amp;rsquo;. Did you mean: &amp;lsquo;zipimporter&amp;rsquo;?&amp;quot;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;This is a tale of upgrading Python 3.12&lt;/p&gt;&#xA;&lt;p&gt;I ran into this error while I was trying to update a project to test on Python 3.12:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  ...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  File &amp;#34;/Users/okken/Library/Application Support/virtualenv/wheel/house/pip-23.0.1-py3-none-any.whl/pip/_internal/metadata/importlib/_envs.py&amp;#34;, line 123, in _find_eggs_in_zip&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    from pip._vendor.pkg_resources import find_eggs_in_zip&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  File &amp;#34;/Users/okken/Library/Application Support/virtualenv/wheel/house/pip-23.0.1-py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py&amp;#34;, line 2164, in &amp;lt;module&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    register_finder(pkgutil.ImpImporter, find_on_path)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;                    ^^^^^^^^^^^^^^^^^^^&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;AttributeError: module &amp;#39;pkgutil&amp;#39; has no attribute &amp;#39;ImpImporter&amp;#39;. Did you mean: &amp;#39;zipimporter&amp;#39;?&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;py312: internal error&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Specifically:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Sharing is Caring - Sharing pytest Fixtures - PyCascades 2023</title>
      <link>https://pythontest.com/pycascades-2023/</link>
      <pubDate>Sun, 19 Mar 2023 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/pycascades-2023/</guid>
      <description>&lt;p&gt;Slides and code and such for a talk for PyCascades 2023.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Talk page: &lt;a href=&#34;https://2023.pycascades.com/program/talks/sharing-is-caring-sharing-pytest-fixtures/&#34;&gt;Sharing is Caring - Sharing pytest Fixtures&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Summary:&lt;/p&gt;&#xA;&lt;p&gt;pytest rocks, obviously. When people start using pytest as a team, they often come up with cool fixtures that would be great to share across projects. In fact, many great Python packages come pre-loaded with pytest fixtures. This talk describes how easy it is to share fixtures using the pytest plugin model.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest tips and tricks</title>
      <link>https://pythontest.com/pytest-tips-tricks/</link>
      <pubDate>Mon, 27 Feb 2023 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/pytest-tips-tricks/</guid>
      <description>&lt;p&gt;This is a set of tips/tricks for learning and using pytest.&lt;br&gt;&#xA;I&amp;rsquo;ll probably build on the list, so feel free to share with me items you think should be in the list.&lt;br&gt;&#xA;Many items really deserve more explanation, and maybe full posts. Let me know if there&amp;rsquo;s something you&amp;rsquo;d like more in depth discussion of.&lt;/p&gt;&#xA;&lt;p&gt;Note: I&amp;rsquo;m not numbering these, because I don&amp;rsquo;t want to keep track of order. Also, this is more of a brain dump, and not a prioritized list.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Fixing Circular Imports in Python with Protocol</title>
      <link>https://pythontest.com/fix-circular-import-python-typing-protocol/</link>
      <pubDate>Mon, 23 Jan 2023 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/fix-circular-import-python-typing-protocol/</guid>
      <description>&lt;p&gt;The problem started when I had two classes that needed to talk to each other.  Sometimes, classes need to talk to each other in both directions.&lt;/p&gt;&#xA;&lt;p&gt;The following example is made up, but mostly behaves like the original problem.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s say I have a &lt;code&gt;Director&lt;/code&gt; and an &lt;code&gt;Actor&lt;/code&gt;.&lt;br&gt;&#xA;The &lt;code&gt;Director&lt;/code&gt; tells the &lt;code&gt;Actor&lt;/code&gt; to &lt;code&gt;do_action()&lt;/code&gt;.&lt;br&gt;&#xA;In order to do the action, the &lt;code&gt;Actor&lt;/code&gt; needs to &lt;code&gt;get_data()&lt;/code&gt; from the &lt;code&gt;Director&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s our &lt;strong&gt;director.py&lt;/strong&gt;:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Testing with Python 3.12</title>
      <link>https://pythontest.com/testing-with-python-3-12/</link>
      <pubDate>Mon, 05 Dec 2022 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/testing-with-python-3-12/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://www.python.org/downloads/release/python-3120a2/&#34;&gt;Python 3.12.0a2&lt;/a&gt; is out. So now may be a great time to get your projects to start testing against 3.12.&lt;/p&gt;&#xA;&lt;h2 id=&#34;note-about-alpha-releases-of-python&#34;&gt;Note about alpha releases of Python&lt;/h2&gt;&#xA;&lt;p&gt;This is from &lt;a href=&#34;https://www.python.org/downloads/release/python-3120a2/&#34;&gt;the same link as above&lt;/a&gt;: &amp;ldquo;During the alpha phase, features may be added up until the start of the beta phase (2023-05-08) and, if necessary, may be modified or deleted up until the release candidate phase (2023-07-31). Please keep in mind that this is a preview release and its use is not recommended for production environments.&amp;rdquo;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Talk -  Sharing is Caring - pytest fixture edition</title>
      <link>https://pythontest.com/sharing-pytest-fixtures/</link>
      <pubDate>Sat, 10 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/sharing-pytest-fixtures/</guid>
      <description>&lt;h1 id=&#34;sharing-is-caring-pytest-fixture-edition&#34;&gt;Sharing is Caring, pytest fixture edition&lt;/h1&gt;&#xA;&lt;p&gt;I gave a talk at PyBay 2022 with the above title.&#xA;It&amp;rsquo;s about sharing fixtures.&lt;/p&gt;&#xA;&lt;p&gt;The source code, and the slides, are at &lt;a href=&#34;https://github.com/okken/pytest_fixture_sharing&#34;&gt;github.com/okken/pytest_fixture_sharing&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Current Git CLI workflow</title>
      <link>https://pythontest.com/git-cli-workflow/</link>
      <pubDate>Wed, 13 Apr 2022 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/git-cli-workflow/</guid>
      <description>&lt;h2 id=&#34;workflow&#34;&gt;Workflow&lt;/h2&gt;&#xA;&lt;p&gt;Most of my interactions with git CLI, especially for quick changes, is:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ git checkout main&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ git pull&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ git checkout -b okken_something&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;lt; code changes &amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ git commit -a -m &lt;span class=&#34;s1&#34;&gt;&amp;#39;quick message&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ git push&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then the code review and merge happen on the server.&lt;/p&gt;&#xA;&lt;h2 id=&#34;commands&#34;&gt;Commands&lt;/h2&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s break that down.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;git checkout main&lt;/code&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Start at the main branch.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;git pull&lt;/code&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Grab any changes from remote repo.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;git checkout -b okken_something&lt;/code&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Create and switch to a new branch to start work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;git commit -a -m &#39;quick message&#39;&lt;/code&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Commit changes.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;-a&lt;/code&gt; automatically &amp;ldquo;adds&amp;rdquo; changed and deleted files, but not untracked files.&lt;/li&gt;&#xA;&lt;li&gt;See &lt;a href=&#34;https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--a&#34;&gt;commit -a&lt;/a&gt; docs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;git push&lt;/code&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Push to the remote repo.&lt;/li&gt;&#xA;&lt;li&gt;Normally this would show an error that the branch name doesn&amp;rsquo;t exist on the remote.&lt;/li&gt;&#xA;&lt;li&gt;However, I have a config setting that automatically creates a branch on remote.&lt;/li&gt;&#xA;&lt;li&gt;config setting: &lt;code&gt;git config --global push.default current&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;See &lt;a href=&#34;https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushdefault&#34;&gt;push.default&lt;/a&gt; docs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;with-autocorrect&#34;&gt;With Autocorrect&lt;/h2&gt;&#xA;&lt;p&gt;Even if I mistype a command, it will work:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Lean TDD</title>
      <link>https://pythontest.com/posts/lean-tdd/lean-tdd-in-2022/</link>
      <pubDate>Sun, 20 Feb 2022 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/posts/lean-tdd/lean-tdd-in-2022/</guid>
      <description>&lt;h2 id=&#34;preface&#34;&gt;Preface&lt;/h2&gt;&#xA;&lt;p&gt;Lean TDD is an attempt to reconcile some conflicting aspects of Test Driven Development and Lean Software Development.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve mentioned Lean TDD on &lt;a href=&#34;https://pythontest.com/testandcode&#34;&gt;the podcast&lt;/a&gt; a few times and even tried to do a quick outline at the end of &lt;a href=&#34;https://pythontest.com/testandcode/162&#34;&gt;episode 162&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This post is a more complete outline, or at least a first draft.&lt;/p&gt;&#xA;&lt;h2 id=&#34;in-audio-form&#34;&gt;In audio form&lt;/h2&gt;&#xA;&lt;p&gt;The initial version of this post is also available in audio form as &lt;a href=&#34;https://pythontest.com/testandcode/180&#34;&gt;Test &amp;amp; Code, episode 180&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Pinning Application Dependencies with pip-tools compile</title>
      <link>https://pythontest.com/python/pinning-applications-with-piptools-compile/</link>
      <pubDate>Wed, 09 Jun 2021 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/python/pinning-applications-with-piptools-compile/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/jazzband/pip-tools&#34;&gt;pip-tools&lt;/a&gt; has more functionality than this, but compile alone is quite useful.&lt;/p&gt;&#xA;&lt;p&gt;Start with a loose list of dependencies in &lt;code&gt;requirements.in&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;typer&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;rich&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;requirements.in&lt;/code&gt; file can have things like &lt;code&gt;&amp;gt;=&lt;/code&gt; and such if you have some restrictions on your dependencies.&lt;/p&gt;&#xA;&lt;p&gt;Now install &lt;code&gt;pip-tools&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;pip install pip-tools&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, in create a &lt;code&gt;requirements.txt&lt;/code&gt; file with &lt;code&gt;compile&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;pip-compile requirements.in&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;python -m piptools compile requirements.in&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The output will be shown on stdout, but also in &lt;code&gt;requirements.txt&lt;/code&gt;:&lt;/p&gt;</description>
    </item>
    <item>
      <title>PythonBytes.fm</title>
      <link>https://pythontest.com/news/pythonbytes-fm/</link>
      <pubDate>Thu, 10 Nov 2016 08:49:03 +0000</pubDate>
      <guid>https://pythontest.com/news/pythonbytes-fm/</guid>
      <description>&lt;p&gt;Michael Kennedy from &lt;a href=&#34;http://talkpython.fm&#34;&gt;Talk Python to Me&lt;/a&gt; and I have launched a new podcast, called &lt;a href=&#34;http://pythonbytes.fm&#34;&gt;Python Bytes&lt;/a&gt;, &amp;ldquo;Python headlines delivered directly to your earbuds&amp;rdquo;. It&amp;rsquo;s a weekly short format podcast. Please check it out.&lt;/p&gt;&#xA;&lt;p&gt;The first few weeks of a podcast can really make a difference if we can get a bunch of listeners to try it right away. Please consider leaving a review on &lt;a href=&#34;https://itunes.apple.com/us/podcast/python-bytes/id1173690032&#34;&gt;iTunes&lt;/a&gt;. Even if you don&amp;rsquo;t use iTunes to listen, early reviews can really help with visibility.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Python featured in April issue of PragPub</title>
      <link>https://pythontest.com/publications/python-featured-april-pragpub/</link>
      <pubDate>Wed, 06 Apr 2016 18:04:43 +0000</pubDate>
      <guid>https://pythontest.com/publications/python-featured-april-pragpub/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://pythontest.com/img/pragpub_april_2016.jpg&#34; alt=&#34;PragPub April 2016&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://www.presspadapp.com/digital-magazine/pragpub&#34;&gt;PragPub April 2016&lt;/a&gt; featuring Python (and me)&lt;/p&gt;&#xA;&lt;p&gt;PragPub is the digital magazine put out by Pragmatic Bookshelf, Michael Swaine, and Nancy Groth.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m especially excited about it because I have two articles featured.&lt;br&gt;&#xA;I mostly know Michael from the many years of reading Dr Dobb&amp;rsquo;s.&lt;br&gt;&#xA;And I respect Pragmatic Bookshelf for their work in technical publishing.&lt;/p&gt;&#xA;&lt;p&gt;So I was thrilled to be asked to contribute.&lt;/p&gt;&#xA;&lt;p&gt;From the Contents page:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Given-When-Then</title>
      <link>https://pythontest.com/strategy/given-when-then-2/</link>
      <pubDate>Wed, 10 Feb 2016 06:54:35 +0000</pubDate>
      <guid>https://pythontest.com/strategy/given-when-then-2/</guid>
      <description>&lt;p&gt;Designing your test methods using a simple structure such as given-when-then will help you:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Communicate the purpose of your test more clearly&lt;/li&gt;&#xA;&lt;li&gt;Focus your thinking while writing the test&lt;/li&gt;&#xA;&lt;li&gt;Make test writing faster&lt;/li&gt;&#xA;&lt;li&gt;Make it easier to re-use parts of your test&lt;/li&gt;&#xA;&lt;li&gt;Highlight the assumptions you are making about the test preconditions&lt;/li&gt;&#xA;&lt;li&gt;Highlight what outcomes you are expecting and testing against.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In this post I&amp;rsquo;ll be talking about designing your test cases/test methods using given-when-then.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest expect fixture plugin, iteration 1</title>
      <link>https://pythontest.com/framework/pytest/pytest-expect-plugin-1/</link>
      <pubDate>Tue, 10 Mar 2015 13:28:02 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-expect-plugin-1/</guid>
      <description>&lt;p&gt;This is the first iteration that implements &amp;rsquo;expect&amp;rsquo; as a fixture.&lt;/p&gt;&#xA;&lt;p&gt;This is really the third attempt at an &amp;rsquo;expect()&amp;rsquo; implementation that allows multiple failures per test.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://pythontest.com/strategy/delayed-assert/&#34;&gt;First attempt&lt;/a&gt; was a general solution that works with any test framework, but with a slightly clunky API. The main problem with it was that it required the test to call a final &amp;lsquo;assert_expectations()&amp;rsquo; from the test code. If you forgot to call that function, the failures weren&amp;rsquo;t reported.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://pythontest.com/framework/pytest/pytest-delayed-assert-plugin-1/&#34;&gt;Second attempt&lt;/a&gt; was a pytest plugin implementation that eliminated the need for the &amp;lsquo;assert_expectations()&amp;rsquo; call in the test because it was called automatically. &lt;a href=&#34;https://pythontest.com/framework/pytest/pytest-delayed-assert-plugin-1/#issues&#34;&gt;I wasn&amp;rsquo;t thrilled with this solution.&lt;/a&gt; But it works.&lt;/li&gt;&#xA;&lt;li&gt;In the solution I&amp;rsquo;m presenting in this post, I&amp;rsquo;m moving all of the code into one file and implementing &amp;rsquo;expect&amp;rsquo; as a pytest fixture.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;div class=&#34;callout note &#34;&gt;&#xA;  The end result of all of this is now a plugin called &lt;a href=&#34;https://github.com/okken/pytest-check&#34;&gt;pytest-check&lt;/a&gt;&#xA;&lt;/div&gt;&#xA;&#xA;&lt;p&gt;I think there are advantages to having &amp;rsquo;expect&amp;rsquo; as a fixture.&lt;br&gt;&#xA;Let me know what you think.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Test First Programming / Test First Development</title>
      <link>https://pythontest.com/agile/test-first-programming/</link>
      <pubDate>Tue, 03 Mar 2015 08:19:09 +0000</pubDate>
      <guid>https://pythontest.com/agile/test-first-programming/</guid>
      <description>&lt;p&gt;Occasionally referred to as &amp;ldquo;Test First Development&amp;rdquo;, &amp;ldquo;Test First Programming&amp;rdquo; is a beautiful concept that radically changed the way I approach software development.&lt;/p&gt;&#xA;&lt;p&gt;The ideas of &amp;ldquo;Test First Programming&amp;rdquo; and &amp;ldquo;Test Driven Development&amp;rdquo; are often muddled together.&lt;br&gt;&#xA;However, &amp;ldquo;Test First&amp;rdquo; is powerful enough to stand on it&amp;rsquo;s own.&lt;br&gt;&#xA;I think it&amp;rsquo;s important to present the concepts separately.&lt;/p&gt;&#xA;&lt;p&gt;&amp;ldquo;TDD&amp;rdquo; and many other agile practices build on &amp;ldquo;Test First&amp;rdquo;.&lt;br&gt;&#xA;This isn&amp;rsquo;t just about remembering the past.&lt;br&gt;&#xA;The lessons learned from &amp;ldquo;Test First&amp;rdquo; are still very important.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest delayed assert / multiple failure plugin, iteration 1</title>
      <link>https://pythontest.com/framework/pytest/pytest-delayed-assert-plugin-1/</link>
      <pubDate>Thu, 19 Feb 2015 05:17:48 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-delayed-assert-plugin-1/</guid>
      <description>&lt;p&gt;In &lt;a href=&#34;https://pythontest.com/strategy/delayed-assert/&#34;&gt;Delayed assert / multiple failures per test&lt;/a&gt;, I presented a first attempt at writing an &lt;code&gt;expect()&lt;/code&gt; function that will allow&lt;br&gt;&#xA;a test function to collect multiple failures and not stop execution until the end of the test.&lt;/p&gt;&#xA;&lt;div class=&#34;callout note &#34;&gt;&#xA;  The end result of all of this is now a plugin called &lt;a href=&#34;https://github.com/okken/pytest-check&#34;&gt;pytest-check&lt;/a&gt;&#xA;&lt;/div&gt;&#xA;&#xA;&lt;p&gt;There&amp;rsquo;s one big thing about that method that I don&amp;rsquo;t like.&lt;br&gt;&#xA;I don&amp;rsquo;t like having to call &lt;code&gt;assert_expectations()&lt;/code&gt; within the test.&lt;br&gt;&#xA;It would be cool to push that part into a plugin.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Delayed assert / multiple failures per test</title>
      <link>https://pythontest.com/strategy/delayed-assert/</link>
      <pubDate>Fri, 13 Feb 2015 08:20:14 +0000</pubDate>
      <guid>https://pythontest.com/strategy/delayed-assert/</guid>
      <description>&lt;div class=&#34;callout note &#34;&gt;&#xA;  The end result of all of this is now a plugin called &lt;a href=&#34;https://github.com/okken/pytest-check&#34;&gt;pytest-check&lt;/a&gt;&#xA;&lt;/div&gt;&#xA;&#xA;&lt;p&gt;A test stops execution once it hits a failing assert statement.&lt;br&gt;&#xA;That&amp;rsquo;s kinda the point of an assert statement, though, so that&amp;rsquo;s not surprising.&lt;/p&gt;&#xA;&lt;p&gt;However, sometimes it&amp;rsquo;s useful to continue with the test even with a failing assert.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m going to present one method for getting around this restriction, to test multiple things, allow multiple failures per test, and continue execution after a failure.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Why Most Unit Testing is Waste</title>
      <link>https://pythontest.com/strategy/why-most-unit-testing-is-waste/</link>
      <pubDate>Fri, 01 Aug 2014 12:55:48 +0000</pubDate>
      <guid>https://pythontest.com/strategy/why-most-unit-testing-is-waste/</guid>
      <description>&lt;p&gt;I don&amp;rsquo;t rememember how I ran across this article by James O Coplien. However, I was immediately impressed with the thought and experience that went into this paper.&#xA;Regardless of your viewpoints towards unit tests vs. other types of automated tests, this article is important to read.&lt;br&gt;&#xA;If your first reaction to the title is anger, please take a deep breath, try to keep an open mind, and actually &lt;em&gt;READ&lt;/em&gt; what Cope has to say.&#xA;I am going to reserve my own reactions to this to a future post, as I don&amp;rsquo;t want to color your views before you read it.&#xA;I am posting the entire article with no changes other than formatting.&lt;/p&gt;</description>
    </item>
    <item>
      <title>My reaction to “Is TDD Dead?”</title>
      <link>https://pythontest.com/agile/is-tdd-dead/</link>
      <pubDate>Sun, 25 May 2014 07:26:48 +0000</pubDate>
      <guid>https://pythontest.com/agile/is-tdd-dead/</guid>
      <description>&lt;p&gt;Whatever your stance on the merits or pitfalls of Test Driven Development, I think it&amp;rsquo;s worthwhile and educational to pay attention to a discussion that&amp;rsquo;s going on lately.&lt;/p&gt;&#xA;&lt;h2 id=&#34;testing-is-crucial-but-is-unit-test-focused-tdd-the-right-path&#34;&gt;Testing is crucial. But is unit test focused TDD the right path?&lt;/h2&gt;&#xA;&lt;p&gt;I care about the conversation about TDD because I see serious flaws in the conventional understanding of TDD.&lt;/p&gt;&#xA;&lt;p&gt;Much of the current view of TDD includes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Units are tested in isolation of the rest of the system.&lt;/li&gt;&#xA;&lt;li&gt;Unit tests are more important than any other form of testing.&lt;/li&gt;&#xA;&lt;li&gt;A &amp;ldquo;unit&amp;rdquo; is a class or a function. Nothing larger is a &amp;ldquo;unit&amp;rdquo;.&lt;/li&gt;&#xA;&lt;li&gt;If you test more than one class, that&amp;rsquo;s an integration test.&lt;/li&gt;&#xA;&lt;li&gt;If you test from the API with all resources, that&amp;rsquo;s a system test. Let QA deal with that later. &lt;strong&gt;Isn&amp;rsquo;t that exactly where waterfall failed?&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can&amp;rsquo;t write any production code without a failing test.&lt;/li&gt;&#xA;&lt;li&gt;You have to write only one test at a time, and it must fail.&lt;/li&gt;&#xA;&lt;li&gt;Tests have to be fast.&lt;/li&gt;&#xA;&lt;li&gt;Therefore, they cannot touch hardware, the file system, other services, or database.&lt;/li&gt;&#xA;&lt;li&gt;Tests should be short.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;All of this rubs me the wrong way.&lt;br&gt;&#xA;I&amp;rsquo;ll get to my thoughts later, but my concern about this cemented view of TDD caused me to be very interested in the current talks.&lt;/p&gt;&#xA;&lt;h2 id=&#34;on-to-the-discussion&#34;&gt;On to the discussion&lt;/h2&gt;&#xA;&lt;p&gt;I came in after the 2nd video, while doing research on Agile and TDD.&lt;br&gt;&#xA;I&amp;rsquo;m not sure if the order matters, but here&amp;rsquo;s a list of what I know about the discussions.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Mixing pytest fixture scope</title>
      <link>https://pythontest.com/framework/pytest/pytest-mixing-fixture-scope/</link>
      <pubDate>Tue, 25 Mar 2014 13:00:31 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-mixing-fixture-scope/</guid>
      <description>&lt;p&gt;Let&amp;rsquo;s say I&amp;rsquo;ve got:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a function scope fixture &amp;lsquo;resource_c&amp;rsquo;&lt;/li&gt;&#xA;&lt;li&gt;that uses a module scoped fixture &amp;lsquo;fixture_b&amp;rsquo;&lt;/li&gt;&#xA;&lt;li&gt;that uses a session scoped fixture &amp;lsquo;fixture_a&amp;rsquo;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This all works fine.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;conftest.py:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;pytest&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;scope&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;session&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;resource_a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;[setup] resource_a()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;yield&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;[teardown] resource_a()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;scope&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;module&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;resource_b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;resource_a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;[setup] resource_b()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;yield&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;[teardown] resource_b()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;scope&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;function&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;resource_c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;resource_b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;[setup] resource_c()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;yield&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;[teardown] resource_c()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;test_alpha.py:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_one&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;resource_c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;In test_one()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_two&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;resource_c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;In test_two()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;test_beta.py:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_three&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;resource_c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;In test_three()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_four&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;resource_c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;In test_four()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This seems reasonable to me.&lt;br&gt;&#xA;What do you think will happen?&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest session scoped fixtures</title>
      <link>https://pythontest.com/framework/pytest/pytest-session-scoped-fixtures/</link>
      <pubDate>Tue, 25 Mar 2014 13:00:31 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-session-scoped-fixtures/</guid>
      <description>&lt;p&gt;In &lt;a href=&#34;https://pythontest.com/framework/pytest/pytest-fixture-scope/&#34;&gt;pytest fixture scope&lt;/a&gt;, I noted that you can specify session scope so that a fixture will only run once per test session and be available across multiple test functions, classes, and modules.&lt;/p&gt;&#xA;&lt;p&gt;In this post, I&amp;rsquo;m going to show a simple example so you can see it in action.&lt;/p&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s the table from the &lt;a href=&#34;https://pythontest.com/framework/pytest/pytest-fixture-scope/&#34;&gt;previous post&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;h2 id=&#34;conftest&#34;&gt;A separate file for fixtures, conftest.py&lt;/h2&gt;&#xA;&lt;p&gt;With function, class, and module scope, it is completely reasonable for the fixture code to be in the same file as the tests.&lt;br&gt;&#xA;But now suddenly, with session, that doesn&amp;rsquo;t make sense anymore.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using pytest fixtures by naming them</title>
      <link>https://pythontest.com/framework/pytest/pytest-named-fixtures/</link>
      <pubDate>Wed, 05 Feb 2014 06:23:04 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-named-fixtures/</guid>
      <description>&lt;p&gt;The easiest way to use a fixture is to name it.&lt;/p&gt;&#xA;&lt;p&gt;We can put the fixture name in the parameter list for each test that needs it:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;pytest&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;before&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;before each test&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;before&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;test_1()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;before&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;test_2()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The fixture is going to be called for every test that names the fixture in it&amp;rsquo;s parameter list.&lt;/p&gt;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ pytest -s test_fixture.py &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;=========== test session starts ============&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;collected 2 items                          &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;test_fixture.py &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;before each test&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;test_1()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;before each test&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;test_2()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;============ 2 passed in 0.05s =============&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;callout note &#34;&gt;&#xA;  &lt;p&gt;This post is part of a series on pytest fixtures&lt;/p&gt;</description>
    </item>
    <item>
      <title>Modularity - pytest fixtures using other fixtures</title>
      <link>https://pythontest.com/framework/pytest/pytest-fixture-modularity/</link>
      <pubDate>Wed, 05 Feb 2014 06:22:11 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-fixture-modularity/</guid>
      <description>&lt;p&gt;Tests can use one or more fixture.&lt;/p&gt;&#xA;&lt;p&gt;Fixtures themselves can also use one or more fixtures.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ll rewrite the example from &lt;a href=&#34;https://pythontest.com/framework/pytest/pytest-multiple-fixtures/&#34;&gt;Using multiple pytest fixtures&lt;/a&gt;, but instead of having the tests include all foo, bar, and baz fixtures, I&amp;rsquo;ll chain them together.&lt;/p&gt;&#xA;&lt;p&gt;And one more wrinkle, &amp;rsquo;test_two&amp;rsquo; will only include &amp;lsquo;bar&amp;rsquo;.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;scope&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;module&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;foo&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;foo setup - module fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;yield&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;foo teardown - module fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;bar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;foo&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;bar setup - function fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;yield&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;bar teardown - function fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;baz&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;bar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;baz setup - function fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;yield&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;baz teardown - function fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_one&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;baz&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;in test_one()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_two&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;bar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;# only use bar&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;in test_two()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;output&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using multiple pytest fixtures</title>
      <link>https://pythontest.com/framework/pytest/pytest-multiple-fixtures/</link>
      <pubDate>Wed, 05 Feb 2014 06:22:10 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-multiple-fixtures/</guid>
      <description>&lt;p&gt;In the examples I&amp;rsquo;ve used so far in this series , tests only are using at most one named fixture.&lt;/p&gt;&#xA;&lt;p&gt;You can use more.&lt;/p&gt;&#xA;&lt;p&gt;Simple example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;pytest&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;scope&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;module&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;foo&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;foo setup - module fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;yield&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;foo teardown - module fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;bar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;bar setup - function fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;yield&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;bar teardown - function fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;baz&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;baz setup - function fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;yield&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;baz teardown - function fixture&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_one&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;foo&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;bar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;baz&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;in test_one()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_two&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;foo&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;bar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;baz&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;in test_two()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ pytest -s test_multiple.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;================== test session starts ==================&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;collected 2 items                                       &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;test_multiple.py &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;foo setup - module fixture&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;bar setup - function fixture&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;baz setup - function fixture&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;in test_one()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;.baz teardown - function fixture&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;bar teardown - function fixture&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;bar setup - function fixture&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;baz setup - function fixture&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;in test_two()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;.baz teardown - function fixture&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;bar teardown - function fixture&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;foo teardown - module fixture&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;=================== 2 passed in 0.06s ===================&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;callout note &#34;&gt;&#xA;  &lt;p&gt;This post is part of a series on pytest fixtures&lt;/p&gt;</description>
    </item>
    <item>
      <title>Parametrizing pytest fixtures with params</title>
      <link>https://pythontest.com/framework/pytest/pytest-parametrize-fixtures/</link>
      <pubDate>Wed, 05 Feb 2014 06:22:09 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-parametrize-fixtures/</guid>
      <description>&lt;p&gt;An optional parameter to the fixture decorator is &lt;code&gt;params&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For each value in params, the fixture will be called with &lt;code&gt;request.param&lt;/code&gt; filled in with that value.&lt;br&gt;&#xA;Tests that use the fixture will be called once FOR EACH value in &lt;code&gt;params&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h3 id=&#34;toy&#34;&gt;Toy example&lt;/h3&gt;&#xA;&lt;p&gt;An example is in order here.&lt;/p&gt;&#xA;&lt;p&gt;This first example is a silly one, but does show the mechanics, and the utility of both the -v flag and how well pytest deals with failures of parameterized tests.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest fixture scope</title>
      <link>https://pythontest.com/framework/pytest/pytest-fixture-scope/</link>
      <pubDate>Wed, 05 Feb 2014 06:22:08 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-fixture-scope/</guid>
      <description>&lt;p&gt;Scope controls how often a fixture gets called.&lt;/p&gt;&#xA;&lt;p&gt;The default is &amp;ldquo;function&amp;rdquo;.&lt;/p&gt;&#xA;&lt;p&gt;Here are the options for scope:&lt;/p&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th&gt;scope&lt;/th&gt;&#xA;          &lt;th&gt;When setup and teardown run&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;function&lt;/td&gt;&#xA;          &lt;td&gt;(default) Setup before each function, teardown after each function&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;class&lt;/td&gt;&#xA;          &lt;td&gt;Setup before first test of class, teardown after last test of class&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;module&lt;/td&gt;&#xA;          &lt;td&gt;Setup/Teardown bracketing tests of a module&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;package&lt;/td&gt;&#xA;          &lt;td&gt;Setup/Teardown bracketing tests of a package/directory&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;session&lt;/td&gt;&#xA;          &lt;td&gt;Setup/Teardown at the beginning and end of the entire test session / test run&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;Since the default scope is &amp;ldquo;function&amp;rdquo;, the &lt;a href=&#34;https://pythontest.com/framework/pytest/pytest-fixture-teardown/&#34;&gt;cheese db example&lt;/a&gt; will open and close the db for every test.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest fixture return value</title>
      <link>https://pythontest.com/framework/pytest/pytest-fixture-return-value/</link>
      <pubDate>Wed, 05 Feb 2014 06:22:07 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-fixture-return-value/</guid>
      <description>&lt;p&gt;In the &lt;a href=&#34;https://pythontest.com/framework/pytest/basic-pytest-fixtures-example/&#34;&gt;basic example&lt;/a&gt;, the fixture returns &lt;code&gt;None&lt;/code&gt;.&lt;br&gt;&#xA;It actually doesn&amp;rsquo;t have a return statement. So like any other function in Python, if you don&amp;rsquo;t supply a &lt;code&gt;return&lt;/code&gt; (or &lt;code&gt;yield&lt;/code&gt;) statement, it returns &lt;code&gt;None&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, you can return anything you want from the fixture function.&lt;br&gt;&#xA;If your fixture is setting up some data, or reading a file, or opening a connection to a database, then access to that data or resources is what you ought to return from the fixture.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest fixture teardown</title>
      <link>https://pythontest.com/framework/pytest/pytest-fixture-teardown/</link>
      <pubDate>Wed, 05 Feb 2014 06:22:07 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-fixture-teardown/</guid>
      <description>&lt;p&gt;In the &lt;a href=&#34;https://pythontest.com/framework/pytest/pytest-fixture-return-value/&#34;&gt;previous post about return value&lt;/a&gt; the &amp;lsquo;cheese_db&amp;rsquo; fixture looked like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;cheese_db&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;request&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# setup&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;[setup] cheese_db, connect to db&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# code to connect to your db &lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;makeshift_cheese_db&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;Brie&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;No.&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;Camenbert&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;Ah! We have Camenbert, yessir.&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# return db to test code&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;makeshift_cheese_db&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That&amp;rsquo;s really not going to work if we have a real database or other resource that we need to possibly, actually &lt;code&gt;disconnect&lt;/code&gt; from when we&amp;rsquo;re done.&lt;/p&gt;&#xA;&lt;p&gt;For resources where we need some code to happen &amp;ldquo;when we&amp;rsquo;re done&amp;rdquo; with them, we use the teardown section of fixtures.&lt;br&gt;&#xA;The &amp;ldquo;teardown&amp;rdquo; section is just &amp;ldquo;anything after a yield&amp;rdquo;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using pytest fixtures with mark.usefixtures</title>
      <link>https://pythontest.com/framework/pytest/pytest-mark-usefixtures/</link>
      <pubDate>Wed, 05 Feb 2014 06:22:06 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-mark-usefixtures/</guid>
      <description>&lt;h3 id=&#34;usefixtures&#34;&gt;Usefixtures example&lt;/h3&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s go back to our &lt;a href=&#34;https://pythontest.com/framework/pytest/basic-pytest-fixtures-example/&#34;&gt;basic example&lt;/a&gt;, but explore the use of &lt;code&gt;usefixtures&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;usefixtures&lt;/code&gt; is a marker that accepts a list of fixture names as strings, and applies it to something.&lt;/p&gt;&#xA;&lt;p&gt;You can use it on an individual test. However, it&amp;rsquo;d be pretty silly as named parameters are easier.&lt;/p&gt;&#xA;&lt;p&gt;However, this is what it&amp;rsquo;d look like to mark individual tests:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# test_usefixtures.py&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;pytest&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.fixture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;before&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;before each test&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.mark.usefixtures&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;before&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;...&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@pytest.mark.usefixtures&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;before&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;...&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And it also works for test methods:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using pytest autouse fixtures</title>
      <link>https://pythontest.com/framework/pytest/pytest-autouse-fixtures/</link>
      <pubDate>Wed, 05 Feb 2014 06:22:05 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-autouse-fixtures/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;framework/pytest/pytest-named-fixtures/&#34;&gt;Naming a fixture&lt;/a&gt; is the most straight-forward way to use fixtures. However, it also requires that we have to add the fixture name to every test that we want to use the fixture.&lt;/p&gt;&#xA;&lt;p&gt;There are times when we want something to happen before every test, and the test itself doesn&amp;rsquo;t really need to know about it. For that, we can use &lt;code&gt;autouse&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you add &lt;code&gt;autouse=True&lt;/code&gt; as a parameter to &lt;code&gt;@pytest.fixture()&lt;/code&gt;, then all tests that have access to this fixture will use the fixture.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Basic pytest fixtures example</title>
      <link>https://pythontest.com/framework/pytest/basic-pytest-fixtures-example/</link>
      <pubDate>Wed, 05 Feb 2014 06:22:03 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/basic-pytest-fixtures-example/</guid>
      <description>&lt;h2 id=&#34;fixtures-hold-setup-code&#34;&gt;Fixtures hold setup code&lt;/h2&gt;&#xA;&lt;p&gt;Fixtures are a way to separate some code that we want to run before or after a test and put it in a different function than the test function itself.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s say we have a couple of tests with common setup code:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# setup code running before the test&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;before each test&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# actual test code&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;test_1()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test_2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# setup code running before the test&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;before each test&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# actual test code&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;test_2()&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;we-could-use-xunit-fixtures-but-were-not-going-to&#34;&gt;We could use xunit fixtures, but we&amp;rsquo;re not going to&lt;/h2&gt;&#xA;&lt;p&gt;If we want to use &lt;a href=&#34;https://pythontest.com/framework/pytest/pytest-xunit-style-fixtures/&#34;&gt;xunit fixtures&lt;/a&gt;, we could create a setup function like:&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest xUnit style fixtures</title>
      <link>https://pythontest.com/framework/pytest/pytest-xunit-style-fixtures/</link>
      <pubDate>Sat, 28 Dec 2013 10:08:14 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-xunit-style-fixtures/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m going to cover the syntax for pytest support for xUnit style fixtures.&lt;br&gt;&#xA;Then I&amp;rsquo;ll give a more reasonable and typical example, using just one set of fixture functions.&lt;br&gt;&#xA;And then address the issue of having tests mixed in a file. Some that need the resource, and some that don&amp;rsquo;t.&lt;/p&gt;&#xA;&lt;p&gt;Depending on what scope you want your fixtures, you define setup/teardown pairs.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Module (setup_module/teardown_module)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Sets things up once for the module, teardown after everything.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Function (setup_function/teardown_function)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Wraps every test function with calls.&lt;/li&gt;&#xA;&lt;li&gt;Gets called multiple times, once for each function&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Class (setup_class/teardown_class)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Like module level, but for classes, once for a class.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Method (setup_method/teardown_method)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Like function level, but for classes.&lt;/li&gt;&#xA;&lt;li&gt;Gets called multiple times, once for each test method in a class&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;callout note &#34;&gt;&#xA;  &lt;p&gt;Unless you really need xUnit fixtures, I recommend completely ignoring this post.&lt;br&gt;&#xA;It&amp;rsquo;s way better to move on and use only native pytest fixtures.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest fixtures nuts and bolts</title>
      <link>https://pythontest.com/framework/pytest/pytest-fixtures/</link>
      <pubDate>Mon, 18 Nov 2013 01:54:23 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-fixtures/</guid>
      <description>&lt;p&gt;Dealing with fixtures is one of the areas where pytest really shines.&lt;br&gt;&#xA;This is rather an incredible understatement.&lt;/p&gt;&#xA;&lt;p&gt;The xunit style of test fixtures that is used in both unittest and nose is of course supported with with pytest. And pytest rocks at this.&lt;/p&gt;&#xA;&lt;p&gt;But there is another way to deal with fixtures. It&amp;rsquo;s to think of fixtures as a set of resources that need to be set up before a test starts, and cleaned up after. Test functions, methods, classes, name which fixtures they need. This way, fixtures aren&amp;rsquo;t set up for tests that don&amp;rsquo;t need them.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The power of “Thank You”</title>
      <link>https://pythontest.com/community/power-of-thank-you/</link>
      <pubDate>Tue, 01 Oct 2013 23:39:59 +0000</pubDate>
      <guid>https://pythontest.com/community/power-of-thank-you/</guid>
      <description>&lt;blockquote&gt;&#xA;&lt;p&gt;Fozzie: Nobody reads those names anyway, do they?&lt;br&gt;&#xA;Kermit: Sure. They all have families.&lt;/p&gt;&#xA;&lt;p&gt;&amp;ndash; &lt;a href=&#34;http://www.imdb.com/title/tt0082474/quotes?qt=qt0449460&#34;&gt;The Great Muppet Caper&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Many projects have release notes that include the names of people that contributed to the release.&lt;/p&gt;&#xA;&lt;p&gt;Who reads these names? &lt;br&gt;&#xA;Well, at the very least, the people in that list read the names.&lt;/p&gt;&#xA;&lt;p&gt;If your project doesn&amp;rsquo;t do this, I think it should.&lt;br&gt;&#xA;My name was listed in a release notice today.&lt;br&gt;&#xA;I&amp;rsquo;ll share the details, and try to point out why saying thanks to contributors is a good idea.&lt;/p&gt;</description>
    </item>
    <item>
      <title>tip: dictionary get() works like getattr</title>
      <link>https://pythontest.com/python/dict-get-like-getattr/</link>
      <pubDate>Wed, 21 Aug 2013 19:14:26 +0000</pubDate>
      <guid>https://pythontest.com/python/dict-get-like-getattr/</guid>
      <description>&lt;p&gt;You can&amp;rsquo;t use &lt;code&gt;getattr()&lt;/code&gt; to look stuff up in a dictionary.&lt;br&gt;&#xA;But the &amp;lsquo;default&amp;rsquo; feature of &lt;code&gt;getattr()&lt;/code&gt; is so useful.&lt;br&gt;&#xA;What&amp;rsquo;s the dict way to do the same thing?&lt;/p&gt;&#xA;&lt;p&gt;This is one of &lt;a href=&#34;https://pythontest.com/python/annoyed-ternary-operator/&#34;&gt;those posts&lt;/a&gt; that I&amp;rsquo;m writing because I keep having to look it up.&lt;br&gt;&#xA;So if I write it, I&amp;rsquo;ll remember it. Hopefully.&lt;/p&gt;&#xA;&lt;h2 id=&#34;getattr&#34;&gt;getattr&lt;/h2&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve been using the &amp;lsquo;default&amp;rsquo; parameter to getattr for some time, and it&amp;rsquo;s super handy.&lt;br&gt;&#xA;This is handy in lots of places, and avoids having to wrap things in try/except blocks.&lt;/p&gt;</description>
    </item>
    <item>
      <title>I’m annoyed with Python’s ternary operator</title>
      <link>https://pythontest.com/python/annoyed-ternary-operator/</link>
      <pubDate>Tue, 02 Jul 2013 16:14:23 +0000</pubDate>
      <guid>https://pythontest.com/python/annoyed-ternary-operator/</guid>
      <description>&lt;p&gt;The ternary operator is a way to concisely say:&lt;br&gt;&#xA;“If &lt;strong&gt;test&lt;/strong&gt;, then &lt;strong&gt;a&lt;/strong&gt;, else &lt;strong&gt;b&lt;/strong&gt;“,&lt;br&gt;&#xA;with the value of the statement being the value of &lt;strong&gt;a&lt;/strong&gt; or &lt;strong&gt;b&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th&gt;language&lt;/th&gt;&#xA;          &lt;th&gt;how to say it&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;C&lt;/td&gt;&#xA;          &lt;td&gt;test ? a : b&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;C++&lt;/td&gt;&#xA;          &lt;td&gt;test ? a : b&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;javascript&lt;/td&gt;&#xA;          &lt;td&gt;test ? a : b&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Perl (not perl 6)&lt;/td&gt;&#xA;          &lt;td&gt;test ? a : b&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;PHP&lt;/td&gt;&#xA;          &lt;td&gt;test ? a : b&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Ruby&lt;/td&gt;&#xA;          &lt;td&gt;test ? a : b&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Did I forget some language?&lt;/td&gt;&#xA;          &lt;td&gt;probably&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Python&lt;/td&gt;&#xA;          &lt;td&gt;a if test else b &lt;strong&gt;(Why??)&lt;/strong&gt;&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h2 id=&#34;why&#34;&gt;Why??&lt;/h2&gt;&#xA;&lt;p&gt;Ok. Now that I’ve written this post, I’ll remember it.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest support for unittest style fixtures</title>
      <link>https://pythontest.com/framework/pytest/pytest-unittest-style-fixtures/</link>
      <pubDate>Wed, 26 Jun 2013 21:07:11 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-unittest-style-fixtures/</guid>
      <description>&lt;p&gt;unittest fixtures behave the same regardless if you run them from &lt;code&gt;python -m unittest&lt;/code&gt; or &lt;code&gt;pytest&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There used to be more of a story here.&lt;/p&gt;&#xA;&lt;p&gt;Way back in 2013 with pytest 2.3.5 (when this post was originally written) there was an issue that the behavior of whether or not to run the teardown for unittest fixtures if the setup failed was different.&lt;/p&gt;&#xA;&lt;p&gt;However, that&amp;rsquo;s been fixed A LONG TIME AGO.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Run a single test class with unittest and pytest</title>
      <link>https://pythontest.com/framework/specify-test-unittest-pytest/</link>
      <pubDate>Wed, 19 Jun 2013 14:10:19 +0000</pubDate>
      <guid>https://pythontest.com/framework/specify-test-unittest-pytest/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve got the test code from my &lt;a href=&#34;https://pythontest.com/framework/unittest/unittest-fixtures&#34;&gt;unittest fixture syntax and flow reference&lt;/a&gt;, and I want to try to run one class, say &lt;code&gt;TestSkip&lt;/code&gt; from unittest and pytest to compare the the control flow.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, I need for each framework:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The option to make it as quiet as possible&#xA;&lt;ul&gt;&#xA;&lt;li&gt;-q for both unittest and pytest&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;The option to turn off output capture&#xA;&lt;ul&gt;&#xA;&lt;li&gt;-s works for pytest, not needed for unittest&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;The way to call an individual class&#xA;&lt;ul&gt;&#xA;&lt;li&gt;details below&lt;/li&gt;&#xA;&lt;li&gt;note that moduleName == fileName (but without the extension)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;unittest&#34;&gt;unittest&lt;/h2&gt;&#xA;&lt;p&gt;Specify &lt;code&gt;moduleName.className&lt;/code&gt;, like so:&lt;/p&gt;</description>
    </item>
    <item>
      <title>What happens when unittest fixtures fail</title>
      <link>https://pythontest.com/framework/unittest/when-unittest-fixtures-fail/</link>
      <pubDate>Mon, 17 Jun 2013 16:50:05 +0000</pubDate>
      <guid>https://pythontest.com/framework/unittest/when-unittest-fixtures-fail/</guid>
      <description>&lt;p&gt;In &lt;a href=&#34;https://pythontest.com/framework/unittest/unittest-fixtures&#34;&gt;unittest fixture syntax and flow reference&lt;/a&gt;, I only presented fixture methods and functions that threw no exceptions.&lt;br&gt;&#xA;However, in real production code, it is entirely possible for something to go wrong when setting up test fixtures.&lt;/p&gt;&#xA;&lt;p&gt;This post is simply do demonstrate exactly what happens to the flow of your test code when an exception is thrown in a fixture function.&lt;/p&gt;&#xA;&lt;p&gt;And, while I&amp;rsquo;m at it, I may as well demo the normal control flow when a test fails, asserts, or throws an exception.&lt;/p&gt;</description>
    </item>
    <item>
      <title>unittest fixture syntax and flow reference</title>
      <link>https://pythontest.com/framework/unittest/unittest-fixtures/</link>
      <pubDate>Sun, 16 Jun 2013 00:15:33 +0000</pubDate>
      <guid>https://pythontest.com/framework/unittest/unittest-fixtures/</guid>
      <description>&lt;p&gt;This post contains examples of how unittest test fixture functions and methods are written, and in what order they run. It may seem like a long post, but it&amp;rsquo;s mostly code examples and example output.&lt;/p&gt;&#xA;&lt;p&gt;I want this to be a useful reference for both the syntax and flow of unittest fixtures.&lt;/p&gt;&#xA;&lt;h2 id=&#34;intro&#34;&gt;Intro: Software Test Fixtures&lt;/h2&gt;&#xA;&lt;p&gt;The term &lt;strong&gt;test fixtures&lt;/strong&gt; really means two things.&lt;br&gt;&#xA;Test fixtures are the resources and initial conditions that a test needs to operate correctly and independently from other tests.&lt;br&gt;&#xA;The phrase has also grown to mean the functions and methods that are used to do that resource and environment handling.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Complete coverage testing from the bottom of the pyramid up is a bad idea</title>
      <link>https://pythontest.com/strategy/complete-coverage-testing/</link>
      <pubDate>Tue, 21 May 2013 14:14:49 +0000</pubDate>
      <guid>https://pythontest.com/strategy/complete-coverage-testing/</guid>
      <description>&lt;p&gt;or &lt;strong&gt;Complete coverage testing&lt;/strong&gt;&lt;br&gt;&#xA;or &lt;strong&gt;More is Better testing&lt;/strong&gt;&lt;br&gt;&#xA;or &lt;strong&gt;How not to test, part 1&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-setup&#34;&gt;The setup&lt;/h2&gt;&#xA;&lt;p&gt;For the sake of this post, let&amp;rsquo;s say I&amp;rsquo;ve got a Python package that needs testing.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It&amp;rsquo;s written completely in Python&lt;/li&gt;&#xA;&lt;li&gt;It has a specification fully describing the API&lt;/li&gt;&#xA;&lt;li&gt;The specification is so complete that it also covers behaviors and side effects&lt;/li&gt;&#xA;&lt;li&gt;The API is the only interface this program exposes&lt;/li&gt;&#xA;&lt;li&gt;It was written by us&lt;/li&gt;&#xA;&lt;li&gt;It was written recently&lt;/li&gt;&#xA;&lt;li&gt;It only uses base Python&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Therefore:&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest debug print logging in real time</title>
      <link>https://pythontest.com/framework/pytest/pytest-logging-real-time/</link>
      <pubDate>Thu, 04 Apr 2013 02:23:18 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-logging-real-time/</guid>
      <description>&lt;p&gt;There are many circumstances where it&amp;rsquo;s really great to display the print statements and logging from a test while a test is running, and not wait until the end.&lt;/p&gt;&#xA;&lt;h2 id=&#34;printing-and-logging-in-test-code&#34;&gt;Printing and logging in test code&lt;/h2&gt;&#xA;&lt;p&gt;Before you pipe in with &amp;ldquo;unit tests should be fast&amp;rdquo;, I&amp;rsquo;ll just remind you that pytest can be used for system tests, performance tests, and other long running tests, and can be used to test both software and hardware.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Python regex Search and Replace Examples</title>
      <link>https://pythontest.com/python/regex-search-replace/</link>
      <pubDate>Fri, 08 Feb 2013 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/python/regex-search-replace/</guid>
      <description>&lt;p&gt;Search and replace is such a common task that it should be a tool that&amp;rsquo;s in every command line script author&amp;rsquo;s toolbox.&lt;br&gt;&#xA;There are probably endless solutions to the problem.&lt;br&gt;&#xA;I&amp;rsquo;ve put together my standard methods for tackling the problem.&lt;br&gt;&#xA;I&amp;rsquo;ll also show similar Perl versions, mainly for comparisons.&lt;/p&gt;&#xA;&lt;h2 id=&#34;use-models&#34;&gt;use models&lt;/h2&gt;&#xA;&lt;p&gt;In most of the following discussion, I&amp;rsquo;m just replacing &amp;lsquo;foo&amp;rsquo; with &amp;lsquo;bar&amp;rsquo;.&lt;br&gt;&#xA;&lt;strong&gt;However &amp;lsquo;foo&amp;rsquo; can be ANY regular expression.&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Perl regex Search and Replace Examples</title>
      <link>https://pythontest.com/perl/regex-search-replace/</link>
      <pubDate>Thu, 07 Feb 2013 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/perl/regex-search-replace/</guid>
      <description>&lt;p&gt;Search and replace is such a common task that it should be a tool that&amp;rsquo;s in every command line script author&amp;rsquo;s toolbox.&lt;br&gt;&#xA;There are probably endless solutions to the problem.&lt;br&gt;&#xA;I&amp;rsquo;ve put together my standard methods for tackling the problem, with Perl.&#xA;&lt;a href=&#34;https://pythontest.com/blog/2013-02-07-python-regex-search-replace-examples.md&#34;&gt;You can also use Python&lt;/a&gt;, of course, as well as other tools like &lt;code&gt;sed&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;use-models&#34;&gt;Use Models&lt;/h2&gt;&#xA;&lt;p&gt;In most of the following discussion, I&amp;rsquo;m just replacing &amp;lsquo;foo&amp;rsquo; with &amp;lsquo;bar&amp;rsquo;.&lt;br&gt;&#xA;&lt;strong&gt;However &amp;lsquo;foo&amp;rsquo; can be ANY regular expression.&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Don&#39;t use nose</title>
      <link>https://pythontest.com/framework/nose/nose-not-recommended/</link>
      <pubDate>Tue, 29 Jan 2013 15:51:12 +0000</pubDate>
      <guid>https://pythontest.com/framework/nose/nose-not-recommended/</guid>
      <description>&lt;p&gt;As of 2025, nose hasn&amp;rsquo;t been updated for about 10 years.&lt;/p&gt;&#xA;&lt;p&gt;I don&amp;rsquo;t recommend using it.&lt;br&gt;&#xA;I recommend trying out pytest. :)&lt;/p&gt;&#xA;&lt;p&gt;A note on the &lt;a href=&#34;https://nose.readthedocs.io/en/latest/#note-to-users&#34;&gt;nose docs&lt;/a&gt; page recommends using a different project, such pytest or unittest:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Note to Users&lt;/p&gt;&#xA;&lt;p&gt;Nose has been in maintenance mode for the past several years and will likely cease without a new person/team to take over maintainership. New projects should consider using Nose2, py.test, or just plain unittest/unittest2.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Running doctest from pytest</title>
      <link>https://pythontest.com/framework/pytest/running-doctest-from-pytest/</link>
      <pubDate>Tue, 15 Jan 2013 13:39:34 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/running-doctest-from-pytest/</guid>
      <description>&lt;p&gt;You can run some doctests from pytest, according to the documentation.&lt;br&gt;&#xA;However, it can be a bit fiddly.&lt;/p&gt;&#xA;&lt;p&gt;With my examples of &lt;a href=&#34;https://pythontest.com/framework/doctest/doctest-introduction/&#34;&gt;putting doctests in text files&lt;/a&gt;, if I just try running:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ pytest test_unnecessary_math.txt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I get the error:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;... ModuleNotFoundError: No module named &amp;#39;unnecessary_math&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It doesn&amp;rsquo;t seem to like the line &amp;ldquo;from unnecessary_math import multiply&amp;rdquo; from the &lt;code&gt;.txt&lt;/code&gt; file, even thought he file &lt;code&gt;unnecessary_math&lt;/code&gt; is in the same directory.&lt;/p&gt;&#xA;&lt;p&gt;However, if I throw that same like into a &lt;code&gt;conftest.py&lt;/code&gt; file, it seems to work:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Running unittest from pytest</title>
      <link>https://pythontest.com/framework/pytest/running-unittest-from-pytest/</link>
      <pubDate>Tue, 15 Jan 2013 13:38:34 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/running-unittest-from-pytest/</guid>
      <description>&lt;p&gt;To show how pytest handles unittests, here&amp;rsquo;s a sample run of pytest on the simple unittests I wrote in the &lt;a href=&#34;https://pythontest.com/framework/unittest/unittest-introduction/&#34;&gt;unittest introduction&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ pytest test_um_unittest.py &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;======================== test session starts =========================&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;collected 2 items                                                    &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;test_um_unittest.py ..                                         [100%]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;========================= 2 passed in 0.04s ==========================&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ pytest -v test_um_unittest.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;======================== test session starts =========================&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;collected 2 items                                                    &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;test_um_unittest.py::TestUM::test_numbers_3_4 PASSED           [ 50%]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;test_um_unittest.py::TestUM::test_strings_a_3 PASSED           [100%]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;========================= 2 passed in 0.05s ==========================&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As you can see, I didn&amp;rsquo;t provide any extra options, pytest finds unittests automatically.&lt;/p&gt;</description>
    </item>
    <item>
      <title>pytest introduction</title>
      <link>https://pythontest.com/framework/pytest/pytest-introduction/</link>
      <pubDate>Tue, 15 Jan 2013 13:36:34 +0000</pubDate>
      <guid>https://pythontest.com/framework/pytest/pytest-introduction/</guid>
      <description>&lt;p&gt;I think of pytest as the run-anything, no boilerplate, no required api, use-this-unless-you-have-a-reason-not-to test framework.&lt;br&gt;&#xA;This is really where testing gets fun.&lt;br&gt;&#xA;As with previous intro&amp;rsquo;s on this site, I&amp;rsquo;ll run through an overview, then a simple example, then throw pytest at my markdown.py project.&lt;br&gt;&#xA;I&amp;rsquo;ll also cover fixtures, test discovery, and running unittests with pytest.&lt;/p&gt;&#xA;&lt;h2 id=&#34;no_boilerplate&#34;&gt;No boilerplate, no required api&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://pythontest.com/framework/doctest/doctest-introduction/&#34;&gt;doctest&lt;/a&gt; and &lt;a href=&#34;https://pythontest.com/framework/unittest/unittest-introduction/&#34;&gt;unittest&lt;/a&gt; both come with Python.&lt;br&gt;&#xA;They are pretty powerful on their own, and I think you should at least know about those frameworks, and learn how to run them at least on some toy examples, as it gives you a mental framework to view other test frameworks.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Confession … I still use perl on the command line</title>
      <link>https://pythontest.com/perl/command-line-perl/</link>
      <pubDate>Wed, 09 Jan 2013 00:00:04 +0000</pubDate>
      <guid>https://pythontest.com/perl/command-line-perl/</guid>
      <description>&lt;h2 id=&#34;i-have-a-confession-to-make&#34;&gt;I have a confession to make.&lt;/h2&gt;&#xA;&lt;p&gt;I still use Perl. Regularly. But mostly as a command line tool. &lt;em&gt;Is that a reason? or an excuse?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;When I started using Python regularly, I tried to replace my Perl usage.&lt;br&gt;&#xA;Nothing against Perl, I just wanted to force myself to use Python to aid in my learning of the language.&lt;/p&gt;&#xA;&lt;p&gt;I still have quite a few Perl habits that are hard to break.&lt;/p&gt;</description>
    </item>
    <item>
      <title>unittest introduction</title>
      <link>https://pythontest.com/framework/unittest/unittest-introduction/</link>
      <pubDate>Fri, 04 Jan 2013 05:22:18 +0000</pubDate>
      <guid>https://pythontest.com/framework/unittest/unittest-introduction/</guid>
      <description>&lt;p&gt;The unittest test framework is python&amp;rsquo;s xUnit style framework.&lt;br&gt;&#xA;It is a standard module that you already have if you&amp;rsquo;ve got python version 2.1 or greater.&lt;br&gt;&#xA;In this post, I&amp;rsquo;ll cover the basics of how to create and run a simple test using unittest.&lt;br&gt;&#xA;Then I&amp;rsquo;ll show how I&amp;rsquo;m using it to test markdown.py.&lt;/p&gt;&#xA;&lt;h2 id=&#34;overview&#34;&gt;Overview of unittest&lt;/h2&gt;&#xA;&lt;p&gt;The unittest module used to be called PyUnit, due to it&amp;rsquo;s legacy as a xUnit style framework.&lt;br&gt;&#xA;It works much the same as the other styles of xUnit, and if you&amp;rsquo;re familiar with unit testing in other languages, this framework (or derived versions), may be the most comfortable for you.&lt;/p&gt;</description>
    </item>
    <item>
      <title>doctest introduction</title>
      <link>https://pythontest.com/framework/doctest/doctest-introduction/</link>
      <pubDate>Tue, 11 Dec 2012 09:16:43 +0000</pubDate>
      <guid>https://pythontest.com/framework/doctest/doctest-introduction/</guid>
      <description>&lt;p&gt;The doctest test framework is a Python module that comes prepackaged with Python. This post covers the basics of how to put doctests in your code, and outside of your code in a separate file.&lt;/p&gt;&#xA;&lt;p&gt;We start with a simple working example using a silly script called &lt;code&gt;unnecessary_math.py&lt;/code&gt;.&#xA;Then we go on to show how I&amp;rsquo;m using doctest to test markdown.py.&lt;/p&gt;&#xA;&lt;h2 id=&#34;concept&#34;&gt;conceptual model of Python doctest&lt;/h2&gt;&#xA;&lt;p&gt;This is from &lt;a href=&#34;http://docs.python.org/2/library/doctest.html#module-doctest&#34;&gt;python.org&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The doctest module searches for pieces of text that look like interactive Python sessions,&lt;br&gt;&#xA;and then executes those sessions to verify that they work exactly as shown.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Software API/CLI interface adapters</title>
      <link>https://pythontest.com/strategy/software-api-cli-interface-adapters/</link>
      <pubDate>Tue, 27 Nov 2012 14:07:19 +0000</pubDate>
      <guid>https://pythontest.com/strategy/software-api-cli-interface-adapters/</guid>
      <description>&lt;p&gt;While writing software, we are faced with lots and lots of interfaces.&lt;br&gt;&#xA;The public interface for some tool or module or package or whatever is usually referred to as the API, the CLI, or simply the user interface.&lt;br&gt;&#xA;In this post, when considering an interface, I am specifically referring to APIs and CLIs.&lt;/p&gt;&#xA;&lt;p&gt;Sometimes, we find a software component that does exactly what we want, but the interface is not what we want.&lt;br&gt;&#xA;That&amp;rsquo;s where software interface adapters come to the rescue.&lt;br&gt;&#xA;Adapters are helpful in many stages of the design and development of just about anything.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Stub for markdown.py</title>
      <link>https://pythontest.com/strategy/stub-markdown/</link>
      <pubDate>Thu, 25 Oct 2012 16:32:15 +0000</pubDate>
      <guid>https://pythontest.com/strategy/stub-markdown/</guid>
      <description>&lt;p&gt;To explore the concepts of functional testing using python and python testing frameworks, I&amp;rsquo;m building a project to test, markdown.py on &lt;a href=&#34;https://github.com/okken/markdown.py&#34;&gt;github&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In this post, I&amp;rsquo;m discussing the stub implementation that I will use to set up the testing frameworks.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve got my &lt;a href=&#34;https://pythontest.com/strategy/markdown-requirements/&#34;&gt;markdown.py requirements&lt;/a&gt; written.&lt;br&gt;&#xA;An initial set, at least. Enough to get me started.&lt;/p&gt;&#xA;&lt;p&gt;I want to move on to explore testing frameworks and testing strategy.&lt;/p&gt;&#xA;&lt;p&gt;But to do that, it will be helpful to have something to test. So I&amp;rsquo;m going to write a stub for my script. Something that has the right name and interface. I can use it just as I will use the completed script. It just doesn&amp;rsquo;t work yet.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Markdown requirements</title>
      <link>https://pythontest.com/strategy/markdown-requirements/</link>
      <pubDate>Thu, 25 Oct 2012 12:00:16 +0000</pubDate>
      <guid>https://pythontest.com/strategy/markdown-requirements/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve decided to write my own Markdown script,&lt;br&gt;&#xA;possibly for &lt;a href=&#34;https://pythontest.com/markdown/why-markdown/&#34;&gt;dubious reasons&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m getting antsy to code.&lt;/p&gt;&#xA;&lt;p&gt;But before I get started on the testing and implementation, I want to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;write the requirements&lt;/li&gt;&#xA;&lt;li&gt;write a simple stub implementation&lt;/li&gt;&#xA;&lt;li&gt;write a testing strategy&lt;/li&gt;&#xA;&lt;li&gt;explore test frameworks&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Then, FINALLY, I can start testing and implementing.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s take a look at the requirements.&lt;/p&gt;&#xA;&lt;h2 id=&#34;requirements-for-markdown&#34;&gt;Requirements for Markdown&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Written in Python&lt;/li&gt;&#xA;&lt;li&gt;Use only Python standard library packages&lt;/li&gt;&#xA;&lt;li&gt;All contained in one python file&lt;/li&gt;&#xA;&lt;li&gt;Implement enough of the original Markdown functionality to be useful&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;That&amp;rsquo;s it for now.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Why Markdown</title>
      <link>https://pythontest.com/markdown/why-markdown/</link>
      <pubDate>Wed, 17 Oct 2012 00:00:00 +0000</pubDate>
      <guid>https://pythontest.com/markdown/why-markdown/</guid>
      <description>&lt;p&gt;Markdown has very little to do with python testing.&lt;br&gt;&#xA;But I need a project to test, so I&amp;rsquo;m writing my own Markdown script.&lt;br&gt;&#xA;This is a brief introduction to Markdown from my perspective.&lt;/p&gt;&#xA;&lt;h2 id=&#34;writing-html-sucks-use-markdown&#34;&gt;Writing HTML sucks. Use Markdown.&lt;/h2&gt;&#xA;&lt;p&gt;HTML is obviously pretty helpful and critical for the web.&lt;br&gt;&#xA;One goal for HTML was that humans could reasonably easily read, write, and edit it.&lt;br&gt;&#xA;And that kinda works. Sometimes.&lt;br&gt;&#xA;But it&amp;rsquo;s not fun to read or write HTML.  Actually, writing stuff in HTML by hand sucks.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
