Python Unit-testing Notes

December 17, 2014

For awhile now, I’ve been meaning to write a tutorial on unit testing in Python aimed at experienced devs who already know why they should be doing it, and just need to know how to go about it in Python.  This document is as far as I got; it gives a passable overview of how I like to test Python code.  Unfortunately, the mock it presents is über-complex, so it’s not quite the document I wanted to write. But it’s a start, and better than nothing, I guess. :-]

I have a similar doc somewhere for unit-testing C++ code using google-test/google-mock that I’ll post if/when I can hunt it down…

{ 0 comments }

Sometime after upgrading to WordPress 4.0, I discovered that comments were no longer showing up on my blog. This is a Note To Self™ regarding what I did to fix it. This page described exactly the problem I was seeing, but I’m using an even older version of Thesis. Fortunately, the same fix worked, with one small change: I had to apply this tiny patch to the comments.php file the referenced page links to:

--- comments.php.orig	2014-12-17 11:50:39.000000000 -0500
+++ comments.php	2014-12-17 11:50:29.000000000 -0500
@@ -6,7 +6,7 @@
  * @since 1.7
  */
 class thesis_comments {
-	function output_comments($comments, $user_data, $depth = 3) {
+	function output_comments($comments, $user_data=null, $depth = 3) {
 		global $thesis_design;
 		$tab = str_repeat("\t", $depth);

This page warns, rather sternly, that you should upgrade first if using a Thesis version prior to 1.8.5, but… I really don’t have time for that right now. My (possibly egregious) hack seems to work well enough. Putting my slightly modified version of comments.php here for reference. (Note: the file that needs to be replaced is: wp-content/themes/thesis_17/lib/classes/comments.php. There’s another, different comments.php file somewhere in Thesis that I [apparently] didn’t have to touch.)

{ 0 comments }

Apple’s Christmas present to me

December 13, 2014

Ermagherd!! I stupidly decided to update my MB Air to Yosemite yesterday and it broke everything I care about  (Qt Creator, Vim, VMWare Fusion, XCode and homebrew) while adding a bunch of annoying pfaff I’ll never use. (I can now sign PDF’s by scrawling on the trackpad? Seriously? ’Cause that looks awesome.) As a developer […]

Read the full article →

Stupid Vim Tricks Volume XXX

December 1, 2014

Some more esoteric Vim commands I’ve recently learned: CTRL-Y duplicates the previous line, column-by-column CTRL-E duplicates the next line, column-by-column CTRL-A inserts again the previously-inserted text CTRL-R= evaluates an expression typed by the user and inserts the result I knew about the normal mode behavior of CTRL-Y and CTRL-E, but didn’t know they could be […]

Read the full article →

kdbus Update

November 26, 2014

I’ve written about this before (here and here), but the situation with respect to D-Bus latency has evolved quite a bit since then. The first and second salvoes of kdbus patches have been submitted, and it looks more and more likely that  D-Bus support will—in one form or another—make its way into the Linux kernel. […]

Read the full article →

GSL for Code Generation—and more!

February 15, 2014

UPDATE: February 21st, 2014 — I happened across another solution to the same problem: pump.py. It also looks quite interesting, but may be intended for a narrower set of use cases… I ran across the GSL project today and fell heavily in like.  I’m starting to get really interested in code generation as a master-level […]

Read the full article →

Overcommit and OOM on Embedded Linux

November 8, 2013

We have a lot of code at work that checks the return value of malloc() for NULL, but I’ve come across a fair number of posts claiming that this is pointless on most Linux systems because the return value of malloc() is very often a lie (due to overcommit being enabled). This article explains the […]

Read the full article →

Static analysis with clang/scan-build

November 6, 2013

My buddy Jim-James asked me how to get CMake to use clang today, and we wound up figuring out that this works: cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .. Well, it works if you do this first: sudo apt-get install clang Anyway,  the cool thing is, clang’s diagnostic output is much more verbose/helpful than gcc’s. I knew this […]

Read the full article →

Close a Hung SSH Session

October 28, 2013

After 15 years of having to deal with this problem once in a blue moon, I finally got annoyed enough to look up the solution. Just hit ENTER + ~ + . to get out of a hung SSH session. (That’s ENTER, followed by a tilde, followed by a period.)  Kinda handy when you’re debugging […]

Read the full article →

APSW May be Your New Best Friend

September 29, 2013

Someday. Keep this link around. The VFS and virtual table support are intriguing, if nothing else. And (Note To Self), when people talk about pysqlite, they’re (apparently) talking about what you get when you type import sqlite3 in Python.  Oh, and the first link says “APSW always handles Unicode correctly.” Good to know.

Read the full article →