From 3f7a5c489ada79121065e3835008d5ba60038b3d Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 5 Sep 2012 11:49:27 -0400 Subject: fixed some of our unittest convenience methods --- testsuite/common.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'testsuite') diff --git a/testsuite/common.py b/testsuite/common.py index 403d3dda7..9af5e2bc7 100644 --- a/testsuite/common.py +++ b/testsuite/common.py @@ -1,4 +1,5 @@ import os +import re import sys import unittest from mock import patch, MagicMock, _patch, DEFAULT @@ -126,7 +127,7 @@ if not hasattr(unittest.TestCase, "assertItemsEqual"): return result -if True or not hasattr(unittest.TestCase, "assertIn"): +if not hasattr(unittest.TestCase, "assertIn"): # versions of TestCase before python 2.7 and python 3.1 lacked a # lot of the really handy convenience methods, so we provide them # -- at least the easy ones and the ones we use. @@ -139,7 +140,12 @@ if True or not hasattr(unittest.TestCase, "assertIn"): msg = kwargs['msg'] del kwargs['msg'] else: - msg = default_msg % args + try: + msg = default_msg % args + except TypeError: + # message passed as final (non-keyword) argument? + msg = args[-1] + args = args[:-1] assert predicate(*args, **kwargs), msg return inner -- cgit v1.2.3-1-g7c22