kopia lustrzana https://github.com/micropython/micropython-lib
unittest: add assertIsNone() and assertIsNotNone() methods to TestCase
rodzic
711eba3a7e
commit
1260289917
|
@ -1,3 +1,3 @@
|
|||
srctype = micropython-lib
|
||||
type = module
|
||||
version = 0.1
|
||||
version = 0.2
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Ładowanie…
Reference in New Issue