Hi, I'm Daniel Greenfeld, and welcome to my blog. I write about Python, Django, and much more.

cached-property: Don't copy/paste code

Tuesday, July 01, 2014 (permalink)

In Python, the @cached_property decorator is a really nice piece of code. What it does is it caches the result of a property call. The cached result will persist as long as the instance does, so if the instance is passed around and the function subsequently invoked, the cached result ...

Read more ...

awesome-slugify: Human-readable URL slugs from any string (part 2)

Wednesday, January 22, 2014 (permalink)

In my previous blog post I covered using awesome-slugify to capture slugs in both ASCII and unicode. Today I'm covering the definition custom language slugify translation functions.

Defining Custom Language slugify Translation Functions

For those times we need ASCII representation of unicode characters, we can't always use the ...

Read more ...

awesome-slugify: Human-readable URL slugs from any string

Tuesday, January 21, 2014 (permalink)

note: The introduction mentions Django and Plone. However, this is not an article about Django or Plone.

Introduction

Years ago, when I was working with Plone at NASA, one thing I dreaded was when content editors would copy-and-paste from Microsoft Word into the title bar. All kinds of funny characters ...

Read more ...

pytest: no-boilerplate testing (part 3)

Friday, January 17, 2014 (permalink)

In my previous blog post I covered writing exception-based assertions and fixtures. Today I'm going to close things out by demonstrating how to change the behavior of pytest and how to integrate it with Django and setup.py.

Changing the Behavior of pytest

When pytest is called, either via ...

Read more ...

pytest: no-boilerplate testing (part 2)

Thursday, January 16, 2014 (permalink)

In my previous blog post I covered test discovery and writing basic tests using pytest. Today I'm going to cover a few more features that I really enjoy: raises and fixtures.

The Intuitively Named raises context manager

When using pytest, you can assert whether or not an exception occurred ...

Read more ...

pytest: no-boilerplate testing

Wednesday, January 15, 2014 (permalink)

When I first encountered Holger Krekel's pytest this summer on Jeff Knupp's blog I felt like I had been living under a rock for years. I've been using Python's unittest framework since 2006 and nose to find tests since 2008, but here was another test framework ...

Read more ...