tests/extmod: Convert machine1.py test to use unittest.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2024-12-03 15:12:34 +11:00
parent c7c3ffa45f
commit 2c80d36998
2 changed files with 26 additions and 37 deletions

View File

@@ -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()

View File

@@ -1,8 +0,0 @@
<8-bit memory>
ValueError
ValueError
TypeError
TypeError
TypeError
TypeError
TypeError