Commit Graph

18 Commits

Author SHA1 Message Date
David Lechner
3dc324d3f1 tests: Format all Python code with black, except tests in basics subdir.
This adds the Python files in the tests/ directory to be formatted with
./tools/codeformat.py.  The basics/ subdirectory is excluded for now so we
aren't changing too much at once.

In a few places `# fmt: off`/`# fmt: on` was used where the code had
special formatting for readability or where the test was actually testing
the specific formatting.
2020-03-30 13:21:58 +11:00
Damien George
08c1fe5569 py/vm: Don't add traceback info for exceptions that are re-raised.
With this patch exceptions that are re-raised have improved tracebacks
(less confusing, match CPython), and it makes re-raise slightly more
efficient (in time and RAM) because they no longer need to add a traceback.
Also general VM performance is not measurably affected.

Partially fixes issue #2928.
2019-08-28 12:31:53 +10:00
Damien George
16f6169c88 py/vm: Don't add traceback info for exc's propagated through a finally.
With this patch exception tracebacks that go through a finally are improved
(less confusing, match CPython), and it makes finally's slightly more
efficient (in time and RAM) because they no longer need to add a traceback.

Partially fixes issue #2928.
2019-08-28 12:31:49 +10:00
Damien George
b01f66c5f1 py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
Ayke van Laethem
6572029dc0 tests: Make tests work on targets without float support. 2018-08-04 15:14:23 +10:00
Damien George
b92a8adbfa tests: Add tests using "file" argument in print and sys.print_exception. 2018-06-20 16:08:25 +10:00
Paul Sokolovsky
85d809d1f4 tests: Convert remaining "sys.exit()" to "raise SystemExit". 2017-06-10 20:34:38 +03:00
Paul Sokolovsky
3e321f1724 tests/misc/: Make few tests skippable. 2017-03-11 01:17:02 +01:00
Damien George
e08395a35c tests/misc: Add test for line number printing with large bytecode chunk. 2017-02-10 12:02:02 +11:00
Paul Sokolovsky
566d8f1d7e tests: Make "io" modules fixes for CPython compatibility.
Previously, "import _io" worked on both CPython and MicroPython (essentially
by a chance on CPython, as there's not guarantee that its contents will stay
the same across versions), but as the module was renamed to uio, need to use
more robust import sequence for compatibility.
2016-05-02 14:38:07 +03:00
Paul Sokolovsky
8c35f3979c tests: Update for _io/_collections module having been renamed. 2016-05-02 14:15:11 +03:00
Paul Sokolovsky
419bb26ddc tests/print_exception: Use exception which prints the same regardless of config.
NameError may either include offending name or not. Unfortunately, this
change makes test float-dependent. And using integer division leads to
different error message than CPython.
2016-03-07 14:10:06 +07:00
Damien George
34f26ea862 tests: Allow tests to pass against CPython 3.5.
All breaking changes going from 3.4 to 3.5 are contained in
basics/python34.py.
2015-10-02 13:01:47 +01:00
Damien George
4852e09c79 py: Fix adding of traceback so that it appends to existing info.
This makes exception traceback info self contained (ie doesn't rely on
list object, which was a bit of a hack), reduces code size, and reduces
RAM footprint of exception by eliminating the list object.

Addresses part of issue #1126.
2015-02-27 00:36:39 +00:00
Damien George
6936f4626c tests: Get misc/print_exception and pyb/spi working on pyboard. 2014-12-18 13:37:56 +00:00
Damien George
184182d14c tests: Fix print_exception test and re-enable it on Travis CI.
Issue was with uPy: on local machine with micropython-lib installed, io
module is available.  Not the case on Travis CI, where only _io module
is available in uPy.
2014-12-11 17:10:25 +00:00
Damien George
4140e19c8a tests: Fix print_exception.py to work on Travis CI. 2014-12-10 21:45:51 +00:00
Paul Sokolovsky
e8487ea1be tests: Add test for print_exception() function. 2014-12-10 20:48:53 +00:00