summaryrefslogtreecommitdiff
path: root/tests/micropython
diff options
context:
space:
mode:
Diffstat (limited to 'tests/micropython')
-rw-r--r--tests/micropython/heapalloc_bytesio.py3
-rw-r--r--tests/micropython/heapalloc_bytesio2.py20
-rw-r--r--tests/micropython/heapalloc_bytesio2.py.exp1
-rw-r--r--tests/micropython/heapalloc_iter.py3
-rw-r--r--tests/micropython/heapalloc_traceback.py3
-rw-r--r--tests/micropython/heapalloc_traceback.py.exp2
-rw-r--r--tests/micropython/kbd_intr.py3
-rw-r--r--tests/micropython/schedule.py3
8 files changed, 27 insertions, 11 deletions
diff --git a/tests/micropython/heapalloc_bytesio.py b/tests/micropython/heapalloc_bytesio.py
index 2a8d50abe..4aae2abf0 100644
--- a/tests/micropython/heapalloc_bytesio.py
+++ b/tests/micropython/heapalloc_bytesio.py
@@ -1,9 +1,8 @@
try:
import uio
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
import micropython
diff --git a/tests/micropython/heapalloc_bytesio2.py b/tests/micropython/heapalloc_bytesio2.py
new file mode 100644
index 000000000..cd76f5807
--- /dev/null
+++ b/tests/micropython/heapalloc_bytesio2.py
@@ -0,0 +1,20 @@
+# Creating BytesIO from immutable object should not immediately
+# copy its content.
+try:
+ import uio
+ import micropython
+ micropython.mem_total
+except (ImportError, AttributeError):
+ print("SKIP")
+ raise SystemExit
+
+
+data = b"1234" * 256
+
+before = micropython.mem_total()
+
+buf = uio.BytesIO(data)
+
+after = micropython.mem_total()
+
+print(after - before < len(data))
diff --git a/tests/micropython/heapalloc_bytesio2.py.exp b/tests/micropython/heapalloc_bytesio2.py.exp
new file mode 100644
index 000000000..0ca95142b
--- /dev/null
+++ b/tests/micropython/heapalloc_bytesio2.py.exp
@@ -0,0 +1 @@
+True
diff --git a/tests/micropython/heapalloc_iter.py b/tests/micropython/heapalloc_iter.py
index 45d3519e4..79461f999 100644
--- a/tests/micropython/heapalloc_iter.py
+++ b/tests/micropython/heapalloc_iter.py
@@ -2,9 +2,8 @@
try:
import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
try:
from micropython import heap_lock, heap_unlock
diff --git a/tests/micropython/heapalloc_traceback.py b/tests/micropython/heapalloc_traceback.py
index b3795293f..f4212b6ce 100644
--- a/tests/micropython/heapalloc_traceback.py
+++ b/tests/micropython/heapalloc_traceback.py
@@ -5,9 +5,8 @@ import sys
try:
import uio
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# preallocate exception instance with some room for a traceback
global_exc = StopIteration()
diff --git a/tests/micropython/heapalloc_traceback.py.exp b/tests/micropython/heapalloc_traceback.py.exp
index facd0af13..291bbd697 100644
--- a/tests/micropython/heapalloc_traceback.py.exp
+++ b/tests/micropython/heapalloc_traceback.py.exp
@@ -1,5 +1,5 @@
StopIteration
Traceback (most recent call last):
- File , line 23, in test
+ File , line 22, in test
StopIteration:
diff --git a/tests/micropython/kbd_intr.py b/tests/micropython/kbd_intr.py
index a7ce7464b..879c9a229 100644
--- a/tests/micropython/kbd_intr.py
+++ b/tests/micropython/kbd_intr.py
@@ -6,8 +6,7 @@ try:
micropython.kbd_intr
except AttributeError:
print('SKIP')
- import sys
- sys.exit()
+ raise SystemExit
# just check we can actually call it
micropython.kbd_intr(3)
diff --git a/tests/micropython/schedule.py b/tests/micropython/schedule.py
index 3d584eea4..74f90cb2d 100644
--- a/tests/micropython/schedule.py
+++ b/tests/micropython/schedule.py
@@ -6,8 +6,7 @@ try:
micropython.schedule
except AttributeError:
print('SKIP')
- import sys
- sys.exit()
+ raise SystemExit
# Basic test of scheduling a function.