From e93bb50f5f58aa701c94ae7f090b1372580348fd Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 12 May 2014 03:04:36 +0300 Subject: [PATCH] unittest: Implement assertIs. --- unittest/setup.py | 2 +- unittest/unittest.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/unittest/setup.py b/unittest/setup.py index 964603f6..7afb5ca4 100644 --- a/unittest/setup.py +++ b/unittest/setup.py @@ -1,7 +1,7 @@ from distutils.core import setup setup(name='micropython-unittest', - version='0.0.4', + version='0.0.5', description='Reimplementation of unittest package for MicroPython', url='https://github.com/micropython/micropython/issues/405', author='MicroPython Developers', diff --git a/unittest/unittest.py b/unittest/unittest.py index 0dc4cb3a..cab783b0 100644 --- a/unittest/unittest.py +++ b/unittest/unittest.py @@ -4,7 +4,14 @@ class TestCase: assert False, msg def assertEqual(self, x, y, msg=''): - assert x == y, "%r vs (expected) %r" % (x, y) + if not msg: + msg = "%r vs (expected) %r" % (x, y) + assert x == y, msg + + def assertIs(self, x, y, msg=''): + if not msg: + msg = "%r is not %r" % (x, y) + assert x is y, msg def assertTrue(self, x, msg=''): assert x, msg