---
title: "The Zen of python should be the zen of good unit testing"
url: "https://osherove.com/blog/2012/5/2/the-zen-of-python-should-be-the-zen-of-good-unit-testing.md"
canonical: "https://osherove.com/blog/2012/5/2/the-zen-of-python-should-be-the-zen-of-good-unit-testing.html"
published: "2012-05-01T21:20:19"
updated: "2012-05-01T21:20:19"
tags: []
author: "Roy Osherove"
description: "I’ve come across the “ zen of python ”. A list of siple rules for style and thought. Overall, I’ve heard that python folks like to be more explicit, and I always felt it’s a good idea. but when I came across the full…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# The Zen of python should be the zen of good unit testing

By Roy Osherove May 1, 2012

**Historical article** · Originally published May 1, 2012; technical details may be outdated.

I’ve come across the “[zen of python](http://www.python.org/dev/peps/pep-0020/)”. A list of siple rules for style and thought. Overall, I’ve heard that python folks like to be more explicit, and I always felt it’s a good idea. but when I came across the full list, I can see how I believe in most of these thigns when I teach my students about readable, maintinable tests:

The zen of unit testing:

```
    Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    Sparse is better than dense. (? not sure what this means)
    Readability counts.
    Special cases aren't special enough to break the rules. (? not sure it's tru for unit testing style)
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one-- and preferably only one --obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch. (uh.. yeah)
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.
    Namespaces are one honking great idea -- let's do more of those! (not sure..)
```


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
