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")
|
||||
raise SystemExit
|
||||
|
||||
print(machine.mem8)
|
||||
import unittest
|
||||
|
||||
try:
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
def test_mem8_print(self):
|
||||
self.assertEqual(repr(machine.mem8), "<8-bit memory>")
|
||||
|
||||
def test_alignment(self):
|
||||
with self.assertRaises(ValueError):
|
||||
machine.mem16[1]
|
||||
except ValueError:
|
||||
print("ValueError")
|
||||
|
||||
try:
|
||||
with self.assertRaises(ValueError):
|
||||
machine.mem16[1] = 1
|
||||
except ValueError:
|
||||
print("ValueError")
|
||||
|
||||
try:
|
||||
def test_operations(self):
|
||||
with self.assertRaises(TypeError):
|
||||
del machine.mem8[0]
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
try:
|
||||
with self.assertRaises(TypeError):
|
||||
machine.mem8[0:1]
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
try:
|
||||
with self.assertRaises(TypeError):
|
||||
machine.mem8[0:1] = 10
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
try:
|
||||
with self.assertRaises(TypeError):
|
||||
machine.mem8["hello"]
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
try:
|
||||
with self.assertRaises(TypeError):
|
||||
machine.mem8["hello"] = 10
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
|
||||
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