diff options
| author | Dan Halbert <halbert@halwitz.org> | 2018-07-11 16:45:30 -0400 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2018-07-11 16:45:30 -0400 |
| commit | 7c219600a246d8956d0b23ea3f5d125a820e6b6a (patch) | |
| tree | 4cf793a66284322d48a8f430815c31cd1c9ffa1d /tests/cpydiff | |
| parent | 4962468ffffac9ec4e36b2b1fc3f132516df3127 (diff) | |
| parent | 25ae98f07cb3c4488cb955403dfe56b8bb8db6f0 (diff) | |
WIP: after merge; before testing
Diffstat (limited to 'tests/cpydiff')
| -rw-r--r-- | tests/cpydiff/builtin_next_arg2.py | 12 | ||||
| -rw-r--r-- | tests/cpydiff/core_function_unpacking.py | 7 | ||||
| -rw-r--r-- | tests/cpydiff/types_exception_subclassinit.py | 10 | ||||
| -rw-r--r-- | tests/cpydiff/types_float_rounding.py | 2 | ||||
| -rw-r--r-- | tests/cpydiff/types_int_tobytesfloat.py | 10 | ||||
| -rw-r--r-- | tests/cpydiff/types_str_decodeerror.py | 11 | ||||
| -rw-r--r-- | tests/cpydiff/types_str_ljust_rjust.py | 2 |
7 files changed, 20 insertions, 34 deletions
diff --git a/tests/cpydiff/builtin_next_arg2.py b/tests/cpydiff/builtin_next_arg2.py new file mode 100644 index 000000000..5df2d6e70 --- /dev/null +++ b/tests/cpydiff/builtin_next_arg2.py @@ -0,0 +1,12 @@ +""" +categories: Modules,builtins +description: Second argument to next() is not implemented +cause: MicroPython is optimised for code space. +workaround: Instead of ``val = next(it, deflt)`` use:: + + try: + val = next(it) + except StopIteration: + val = deflt +""" +print(next(iter(range(0)), 42)) diff --git a/tests/cpydiff/core_function_unpacking.py b/tests/cpydiff/core_function_unpacking.py deleted file mode 100644 index 01d25ee4d..000000000 --- a/tests/cpydiff/core_function_unpacking.py +++ /dev/null @@ -1,7 +0,0 @@ -""" -categories: Core,Functions -description: Unpacking function arguments in non-last position isn't detected as an error -cause: Unknown -workaround: The syntax below is invalid, never use it in applications. -""" -print(*(1, 2), 3) diff --git a/tests/cpydiff/types_exception_subclassinit.py b/tests/cpydiff/types_exception_subclassinit.py index 177094646..39cdaf45b 100644 --- a/tests/cpydiff/types_exception_subclassinit.py +++ b/tests/cpydiff/types_exception_subclassinit.py @@ -1,8 +1,12 @@ """ categories: Types,Exception -description: Exception.__init__ raises TypeError if overridden and called by subclass -cause: Unknown -workaround: Unknown +description: Exception.__init__ method does not exist. +cause: Subclassing native classes is not fully supported in MicroPython. +workaround: Call using ``super()`` instead:: + + class A(Exception): + def __init__(self): + super().__init__() """ class A(Exception): def __init__(self): diff --git a/tests/cpydiff/types_float_rounding.py b/tests/cpydiff/types_float_rounding.py index 82a149d85..c8d3cfbe8 100644 --- a/tests/cpydiff/types_float_rounding.py +++ b/tests/cpydiff/types_float_rounding.py @@ -5,5 +5,3 @@ cause: Unknown workaround: Unknown """ print('%.1g' % -9.9) -print('%.1e' % 9.99) -print('%.1e' % 0.999) diff --git a/tests/cpydiff/types_int_tobytesfloat.py b/tests/cpydiff/types_int_tobytesfloat.py deleted file mode 100644 index 5d5b980fa..000000000 --- a/tests/cpydiff/types_int_tobytesfloat.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -categories: Types,int -description: Incorrect error message when passing float into to_bytes -cause: Unknown -workaround: Unknown -""" -try: - int('1').to_bytes(1.0) -except TypeError as e: - print(e) diff --git a/tests/cpydiff/types_str_decodeerror.py b/tests/cpydiff/types_str_decodeerror.py deleted file mode 100644 index 944db98fe..000000000 --- a/tests/cpydiff/types_str_decodeerror.py +++ /dev/null @@ -1,11 +0,0 @@ -""" -categories: Types,str -description: UnicodeDecodeError not raised when expected -cause: Unknown -workaround: Unknown -""" -try: - print(repr(str(b"\xa1\x80", 'utf8'))) - print('Should not get here') -except UnicodeDecodeError: - print('UnicodeDecodeError') diff --git a/tests/cpydiff/types_str_ljust_rjust.py b/tests/cpydiff/types_str_ljust_rjust.py index 498596205..fa3f594c1 100644 --- a/tests/cpydiff/types_str_ljust_rjust.py +++ b/tests/cpydiff/types_str_ljust_rjust.py @@ -2,6 +2,6 @@ categories: Types,str description: str.ljust() and str.rjust() not implemented cause: MicroPython is highly optimized for memory usage. Easy workarounds available. -workaround: Instead of `s.ljust(10)` use `"%-10s" % s`, instead of `s.rjust(10)` use `"% 10s" % s`. Alternatively, `"{:<10}".format(s)` or `"{:>10}".format(s)`. +workaround: Instead of ``s.ljust(10)`` use ``"%-10s" % s``, instead of ``s.rjust(10)`` use ``"% 10s" % s``. Alternatively, ``"{:<10}".format(s)`` or ``"{:>10}".format(s)``. """ print('abc'.ljust(10)) |
