aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky2016-07-22 12:02:04 +0300
committerPaul Sokolovsky2016-07-22 12:02:04 +0300
commitb652ee705b7378211250bebb478a3894836350bb (patch)
treec7236b50d27a41628457a501bd939fd971979230
parent40214b9e26408ceb0e4eb92a57f59302b38fa6f9 (diff)
tests/bytes_compare: Rework test for bytes <-> str comparison.
This may produce a warning, depending on MicroPython configuration.
-rw-r--r--tests/basics/bytes_compare2.py1
-rw-r--r--tests/basics/bytes_compare3.py9
-rw-r--r--tests/basics/bytes_compare3.py.exp4
-rwxr-xr-xtests/run-tests3
4 files changed, 15 insertions, 2 deletions
diff --git a/tests/basics/bytes_compare2.py b/tests/basics/bytes_compare2.py
index 02516de93..8959da3ae 100644
--- a/tests/basics/bytes_compare2.py
+++ b/tests/basics/bytes_compare2.py
@@ -1,6 +1,5 @@
print(b"1" == 1)
print(b"123" == bytearray(b"123"))
-print(b"123" == "123")
print(b'123' < bytearray(b"124"))
print(b'123' > bytearray(b"122"))
print(bytearray(b"23") in b"1234")
diff --git a/tests/basics/bytes_compare3.py b/tests/basics/bytes_compare3.py
new file mode 100644
index 000000000..4b9cbd5b3
--- /dev/null
+++ b/tests/basics/bytes_compare3.py
@@ -0,0 +1,9 @@
+# Based on MicroPython config option, comparison of str and bytes
+# or vice versa may issue a runtime warning. On CPython, if run as
+# "python3 -b", only comparison of str to bytes issues a warning,
+# not the other way around (while exactly comparison of bytes to
+# str would be the most common error, as in sock.recv(3) == "GET").
+# Update: the issue above with CPython apparently happens in REPL,
+# when run as a script, both lines issue a warning.
+print("123" == b"123")
+print(b"123" == "123")
diff --git a/tests/basics/bytes_compare3.py.exp b/tests/basics/bytes_compare3.py.exp
new file mode 100644
index 000000000..7b117b905
--- /dev/null
+++ b/tests/basics/bytes_compare3.py.exp
@@ -0,0 +1,4 @@
+########
+False
+########
+False
diff --git a/tests/run-tests b/tests/run-tests
index 02791896b..878c14f26 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -27,9 +27,10 @@ def rm_f(fname):
os.remove(fname)
def run_micropython(pyb, args, test_file):
+ special_tests = ('micropython/meminfo.py', 'basics/bytes_compare3.py')
if pyb is None:
# run on PC
- if test_file.startswith(('cmdline/', 'feature_check/')) or test_file == 'micropython/meminfo.py':
+ if test_file.startswith(('cmdline/', 'feature_check/')) or test_file in special_tests :
# special handling for tests of the unix cmdline program
# check for any cmdline options needed for this test