def shape2d(a):
    if type(a) == int:
        return [a, a]
    if isinstance(a, (list, tuple)):
        assert len(a) == 2
        return list(a)
    raise RuntimeError("Illegal shape: {}".format(a))
Just like self.assertTrue(a < b), but with a nicer default message.
dataset/ETHPy150Open ppwwyyxx/tensorpack/tensorpack/models/_common.py/shape2d--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.3/django/utils/unittest/case.py/TestCase.assertLess