tests/extmod: Convert machine1.py test to use unittest.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -8,39 +8,36 @@ except:
|
|||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
print(machine.mem8)
|
import unittest
|
||||||
|
|
||||||
try:
|
|
||||||
machine.mem16[1]
|
|
||||||
except ValueError:
|
|
||||||
print("ValueError")
|
|
||||||
|
|
||||||
try:
|
class Test(unittest.TestCase):
|
||||||
machine.mem16[1] = 1
|
def test_mem8_print(self):
|
||||||
except ValueError:
|
self.assertEqual(repr(machine.mem8), "<8-bit memory>")
|
||||||
print("ValueError")
|
|
||||||
|
|
||||||
try:
|
def test_alignment(self):
|
||||||
del machine.mem8[0]
|
with self.assertRaises(ValueError):
|
||||||
except TypeError:
|
machine.mem16[1]
|
||||||
print("TypeError")
|
|
||||||
|
|
||||||
try:
|
with self.assertRaises(ValueError):
|
||||||
machine.mem8[0:1]
|
machine.mem16[1] = 1
|
||||||
except TypeError:
|
|
||||||
print("TypeError")
|
|
||||||
|
|
||||||
try:
|
def test_operations(self):
|
||||||
machine.mem8[0:1] = 10
|
with self.assertRaises(TypeError):
|
||||||
except TypeError:
|
del machine.mem8[0]
|
||||||
print("TypeError")
|
|
||||||
|
|
||||||
try:
|
with self.assertRaises(TypeError):
|
||||||
machine.mem8["hello"]
|
machine.mem8[0:1]
|
||||||
except TypeError:
|
|
||||||
print("TypeError")
|
|
||||||
|
|
||||||
try:
|
with self.assertRaises(TypeError):
|
||||||
machine.mem8["hello"] = 10
|
machine.mem8[0:1] = 10
|
||||||
except TypeError:
|
|
||||||
print("TypeError")
|
with self.assertRaises(TypeError):
|
||||||
|
machine.mem8["hello"]
|
||||||
|
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
machine.mem8["hello"] = 10
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
<8-bit memory>
|
|
||||||
ValueError
|
|
||||||
ValueError
|
|
||||||
TypeError
|
|
||||||
TypeError
|
|
||||||
TypeError
|
|
||||||
TypeError
|
|
||||||
TypeError
|
|
||||||
Reference in New Issue
Block a user