Skip to content
Permalink
Browse files

unittest: add assertIsNone() and assertIsNotNone() methods to TestCase

  • Loading branch information...
dxxb authored and Paul Sokolovsky committed Nov 1, 2015
1 parent 711eba3 commit 12602899174ff93824b7214f141120536490e27f
Showing with 22 additions and 2 deletions.
  1. +1 −1 unittest/metadata.txt
  2. +1 −1 unittest/setup.py
  3. +10 −0 unittest/test_unittest.py
  4. +10 −0 unittest/unittest.py
@@ -1,3 +1,3 @@
srctype = micropython-lib
type = module
version = 0.1
version = 0.2
@@ -6,7 +6,7 @@


setup(name='micropython-unittest',
version='0.1',
version='0.2',
description='unittest module for MicroPython',
long_description="This is a module reimplemented specifically for MicroPython standard library,\nwith efficient and lean design in mind. Note that this module is likely work\nin progress and likely supports just a subset of CPython's corresponding\nmodule. Please help with the development if you are interested in this\nmodule.",
url='https://github.com/micropython/micropython/issues/405',
@@ -72,6 +72,16 @@ def testIsNot(self):
with self.assertRaises(AssertionError):
self.assertIsNot(None, None)

def testIsNone(self):
self.assertIsNone(None)
with self.assertRaises(AssertionError):
self.assertIsNone(0)

def testIsNotNone(self):
self.assertIsNotNone(0)
with self.assertRaises(AssertionError):
self.assertIsNotNone(None)

def testTrue(self):
self.assertTrue(True)
with self.assertRaises(AssertionError):
@@ -83,6 +83,16 @@ def assertIsNot(self, x, y, msg=''):
msg = "%r is %r" % (x, y)
assert x is not y, msg

def assertIsNone(self, x, msg=''):
if not msg:
msg = "%r is not None" % x
assert x is None, msg

def assertIsNotNone(self, x, msg=''):
if not msg:
msg = "%r is None" % x
assert x is not None, msg

def assertTrue(self, x, msg=''):
if not msg:
msg = "Expected %r to be True" % x

0 comments on commit 1260289

Please sign in to comment.
You can’t perform that action at this time.