8000 tests/extmod: Convert machine1.py test to use unittest. · micropython/micropython@2c80d36 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2c80d36

Browse files
committed
tests/extmod: Convert machine1.py test to use unittest.
Signed-off-by: Damien George <damien@micropython.org>
1 parent c7c3ffa commit 2c80d36

File tree

2 files changed

+26
-37
lines changed

2 files changed

+26
-37
lines changed

tests/extmod/machine1.py

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,36 @@
88
print("SKIP")
99
raise SystemExit
1010

11-
print(machine.mem8)
11+
import unittest
1212

13-
try:
14-
machine.mem16[1]
15-
except ValueError:
16-
print("ValueError")
1713

18-
try:
19-
machine.mem16[1] = 1
20-
except ValueError:
21-
print("ValueError")
14+
class Test(unittest.TestCase):
15+
def test_mem8_print(self):
16+
self.assertEqual(repr(machine.mem8), "<8-bit memory>")
2217

23-
try:
24-
del machine.mem8[0]
25-
except TypeError:
26-
print("TypeError")
18+
def test_alignment(self):
19+
with self.assertRaises(ValueError):
20+
machine.mem16[1]
2721

28-
try:
29-
machine.mem8[0:1]
30-
except TypeError:
31-
print("TypeError")
22+
with self.assertRaises(ValueError):
23+
machine.mem16[1] = 1
3224

33-
try:
34-
machine.mem8[0:1] = 10
35-
except TypeError:
36-
print("TypeError")
25+
def test_operations(self):
26+
with self.assertRaises(TypeError):
27+
del machine.mem8[0]
3728

38-
try:
39-
machine.mem8["hello"]
40-
except TypeError:
41-
print("TypeError")
29+
with self.assertRaises(TypeError):
30+
machine.mem8[0:1]
4231

43-
try:
44-
machine.mem8["hello"] = 10
45-
except TypeError:
46-
print("TypeError")
32+
with self.assertRaises(TypeError):
33+
machine.mem8[0:1] = 10
34+
35+
with self.assertRaises(TypeError):
36+
machine.mem8["hello"]
37+
38+
with self.assertRaises(TypeError):
39+
machine.mem8["hello"] = 10
40+
41+
42+
if __name__ == "__main__":
43+
unittest.main()

tests/extmod/machine1.py.exp

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0