Adam Johnson

Home | Blog | Training | Projects | Colophon | Contact

Posts tagged ‘python’


A Guide to Python Lambda Functions

It’s a Lamb, Duh

This is a cross-post from the Scout APM blog, where I occasionally write. I also maintain the Scout Python integration.

Read more...

Better Python Decorators with wrapt

Bee likes decorated flowers.

This is a cross-post from the Scout APM blog, where I occasionally write. I also maintain the Scout Python integration, which uses wrapt for its Python decorators.

Read more...

Why does Python raise ModuleNotFoundError when modifying Django's INSTALLED_APPS?

Pegasus, chained

Imagine we are installing the third party package django-cors-headers, which I maintain. Step one in its installation process is to install the package, so we run the command:

Read more...

How to Check if Python's Output Buffering Is Enabled

Buffering

By default, Python buffers output to standard output (stdout) and standard error (stderr). This means that output from your code might not show up immediately, making debugging harder.

Read more...

Why does Python log a SyntaxWarning saying "list indices must be integers or slices"?

Sssssssspam

Take this code, which we want to return a list of two breakfast orders:

Read more...

Why does Python log a SyntaxWarning saying "assertion is always true"?

Wiggle wiggle

Take this code:

Read more...

Why does Python log a SyntaxWarning saying "object is not subscriptable"?

The snake is out of the box now

Take this code:

Read more...

Why does Python log a SyntaxWarning saying "object is not callable"?

Danger snake

Take this code, which we want to return a list of shopping items with desired quantities:

Read more...

How to Unit Test a Django Form

Test this bit, this bit, and this bit

This post is an adapted extract from my book Speed Up Your Django Tests, available now.

Read more...

Avoid Hardcoding ID’s in Your Tests

Between a rock and a hardcoded place

This is a test anti-pattern I’ve seen creep in on many Django test suites. I know of several large projects where it became a major undertaking to undo it. The good news is it’s easy to avoid adding it when you first write your tests. 🙂

Read more...

All tags: