posts

A collection of 65 Posts

Python People podcast now at pythontest.com/pythonpeople

A new home for Python People

Test and Code Archive is now available

The Test and Code podcast is in archive mode, and has moved here...

pytest fixtures nuts and bolts - revisited

A series on pytest fixtures gets updated

Time Machine back to 2012

A review of old posts has begun!

Unravelling t-strings with pytest

Brett Cannon recently released an article explaining Python 3.14's new t-strings. This article has pytest versions of the code from Brett's article.

Testing some tidbits with pytest

I noticed a fun post by Ned Batchelder called "Testing some tidbits". The post looks at different ways to see if a string has only 0 or 1 in it. I'm expanding on that with some pytest code to test the different ways.

Finding the top pytest plugins

What are the top downloaded pytest plugins? I want to know this. And I'd like the answer updated regularly. So today I decided to write a script to do that for me.

pytest 8 is here

A few notes on some cool additions in pytest 8

Testing argparse Applications

CLI testing can be tricky, we unravel it for argparse apps

pytest slow order

Using pytest-skip-slow to control whether or not to run slow tests.

Upgrading to Python 3.12 and my battle with virtualenv cache

Recapping some troubles I had when upgrading

Sharing is Caring - Sharing pytest Fixtures - PyCascades 2023

Slides, link to video, and resources

pytest tips and tricks

This is a set of tips/tricks for learning and using pytest.

Fixing Circular Imports in Python with Protocol

Quick tutorial with example

Testing with Python 3.12

Encouraging people to test

Installing Python 3.11 on Mac or Windows

The easiest way to install Python 3.11

Talk - Sharing is Caring - pytest fixture edition

PyBay talk resources

Current Git CLI workflow

Just documenting my git workflow

Lean TDD

A discussion of some ideas around Lean TDD from 2022. Lean TDD is an attempt to reconcile some conflicting aspects of Test Driven Development and Lean Software Development. I've mentioned Lean TDD on [the podcast][testandcode] a few times and even tried to do a quick outline at the end of [episode 162][flavors]. This post is a more complete outline, or at least a first draft.

Pinning Application Dependencies with pip-tools compile

Pinning dependencies

PythonBytes.fm

Announcing our new podcast

Python featured in April issue of PragPub

Two of my articles published in PragProg

Given-When-Then

Designing your test cases/test methods using given-when-then.

pytest expect fixture plugin, iteration 1

This is the first iteration that implements ’expect’ as a fixture.

This is really the third attempt at an ’expect()’ implementation that …

Test First Programming / Test First Development

Occasionally referred to as “Test First Development”, “Test First Programming” is a beautiful concept that radically changed the way I …

pytest delayed assert / multiple failure plugin, iteration 1

Further thoughts on the way to pytest-check

Delayed assert / multiple failures per test

The start of thinking that led to pytest-check

Why Most Unit Testing is Waste

A re-publishing of James Coplien's article

My reaction to “Is TDD Dead?”

Discussion around the future of TDD

Mixing pytest fixture scope

Fixtures can only use other fixtures with equal or wider scope

pytest session scoped fixtures

We can use conftest.py to define fixtures that can be used by multiple files and still only run once per session

Using pytest fixtures by naming them

Including the fixture name as a parameter

Modularity - pytest fixtures using other fixtures

Fixtures can use other fixtures

Using multiple pytest fixtures

Separate your setup into separate pieces

Parametrizing pytest fixtures with params

Running fixtures (and the tests that depend on them) multiple times with different values

pytest fixture scope

Startup and teardown can surround functions, classes, modules/files, directories, or the entire test session.

pytest fixture return value

Return whatever value you want to the test

pytest fixture teardown

Including teardown code in a fixture

Using pytest fixtures with mark.usefixtures

If you want to apply a fixture to all tests in a class or file

Using pytest autouse fixtures

autouse is powerful and potentially dangerous

Basic pytest fixtures example

Fixtures are used to set up stuff before a test runs

pytest xUnit style fixtures

Using xUnit style with pytest

pytest fixtures nuts and bolts

fixtures reference

The power of “Thank You”

Getting thanked feels good

tip: dictionary get() works like getattr

Default values with dict

I’m annoyed with Python’s ternary operator

rant

pytest support for unittest style fixtures

They behave the same

Run a single test class with unittest and pytest

How to, with examples

What happens when unittest fixtures fail

Exactly what happens to the flow of your test code when an exception is thrown in a fixture function.

unittest fixture syntax and flow reference

a reference

Complete coverage testing from the bottom of the pyramid up is a bad idea

I made some enemies with this post

pytest debug print logging in real time

How to get print to work with tests

Python regex Search and Replace Examples

How I use search and replace in Python

Perl regex Search and Replace Examples

How I use search and replace in perl

Don't use nose

nose not recommended

Running doctest from pytest

You can run some doctests from pytest, according to the documentation.
However, it can be a bit fiddly.

With my examples of putting doctests in text files, if I …

Running unittest from pytest

To show how pytest handles unittests, here’s a sample run of pytest on the simple unittests I wrote in the unittest introduction:

$ pytest …

pytest introduction

I think of pytest as the run-anything, no boilerplate, no required api, use-this-unless-you-have-a-reason-not-to test framework.
This is really where testing …

Confession … I still use perl on the command line

Using search and replace in perl

unittest introduction

The unittest test framework is python’s xUnit style framework.
It is a standard module that you already have if you’ve got python version 2.1 or …

doctest introduction

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 …

Software API/CLI interface adapters

While writing software, we are faced with lots and lots of interfaces.
The public interface for some tool or module or package or whatever is usually referred …

Stub for markdown.py

To explore the concepts of functional testing using python and python testing frameworks, I’m building a project to test, markdown.py on github.

In this …

Markdown requirements

I’ve decided to write my own Markdown script,
possibly for dubious reasons.

I’m getting antsy to code.

But before I get started on the testing and …

Why Markdown

Introduction to Markdown and why I'm going to build a markdown converter.