diff --git a/unittest/metadata.txt b/unittest/metadata.txt index a9a85a5b..a984e65f 100644 --- a/unittest/metadata.txt +++ b/unittest/metadata.txt @@ -1,3 +1,3 @@ srctype = micropython-lib type = module -version = 0.1 +version = 0.2 diff --git a/unittest/setup.py b/unittest/setup.py index c4559833..318fe8b0 100644 --- a/unittest/setup.py +++ b/unittest/setup.py @@ -6,7 +6,7 @@ from setuptools import setup 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', diff --git a/unittest/test_unittest.py b/unittest/test_unittest.py index 01eabe57..5c13b443 100644 --- a/unittest/test_unittest.py +++ b/unittest/test_unittest.py @@ -72,6 +72,16 @@ class TestUnittestAssertions(unittest.TestCase): 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): diff --git a/unittest/unittest.py b/unittest/unittest.py index ab7121b6..48ef7126 100644 --- a/unittest/unittest.py +++ b/unittest/unittest.py @@ -83,6 +83,16 @@ class TestCase: 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