aboutsummaryrefslogtreecommitdiff
path: root/tests/misc
AgeCommit message (Collapse)Author
2020-12-18tests/misc/sys_settrace_features.py: Fix running with non-dflt encoding.stijn
Notably git-cmd which comes with git installations on Windows alters the encoding resulting in CPython tracing encodings/cp1252.py calls.
2020-12-18tests/misc/sys_settrace: Make test output independent of invoked path.stijn
The original logic of reducing a full path to a relative one assumes "tests/misc" is in the filename which is limited in usage: it never works for CPython on Windows since that will use a backslash as path separator, and also won't work when the filename is a path not relative to the tests directory which happens for example in the common case of running "./run-tests -d misc". Fix all cases by printing only the bare filename, which requires them all to start with sys_settrace_ hence the renaming.
2020-12-14tests/misc/sys_settrace_features.py: Ignore CPython zipimport traces.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-09-04all: Rename "sys" module to "usys".stijn
This is consistent with the other 'micro' modules and allows implementing additional features in Python via e.g. micropython-lib's sys. Note this is a breaking change (not backwards compatible) for ports which do not enable weak links, as "import sys" must now be replaced with "import usys".
2020-03-30tests: Format all Python code with black, except tests in basics subdir.David Lechner
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.
2019-10-22tests: Rename "array" module to "uarray".Damien George
2019-08-30tests: Add tests for sys.settrace feature.Milan Rossa
2019-08-28py/vm: Don't add traceback info for exceptions that are re-raised.Damien George
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-28py/vm: Don't add traceback info for exc's propagated through a finally.Damien George
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-15tests/misc/sys_atexit: Add test for new sys.atexit feature.Milan Rossa
2018-10-22tests: Make bytes/str.count() tests skippable.Paul Sokolovsky
2018-09-20py: Shorten error messages by using contractions and some rewording.Damien George
2018-08-17tests: Modify tests that print repr of an exception with 1 arg.Damien George
In Python 3.7 the behaviour of repr() of an exception with one argument changed: it no longer prints a trailing comma in the argument list. See https://bugs.python.org/issue30399 This patch modifies tests that rely on this behaviour to not rely on it. And the python34.py test is updated to include a test for this behaviour with a .exp file.
2018-08-04tests: Make tests work on targets without float support.Ayke van Laethem
2018-06-20tests: Add tests using "file" argument in print and sys.print_exception.Damien George
2018-06-08py/objtype: Optimise instance get/set/del by skipping special accessors.Damien George
This patch is a code optimisation, trading text bytes for speed. On pyboard it's an increase of 0.06% in code size for a gain (in pystone performance) of roughly 6.5%. The patch optimises load/store/delete of attributes in user defined classes by not looking up special accessors (@property, __get__, __delete__, __set__, __setattr__ and __getattr_) if they are guaranteed not to exist in the class. Currently, if you do my_obj.foo() then the runtime has to do a few checks to see if foo is a property or has __get__, and if so delegate the call. And for stores things like my_obj.foo = 1 has to first check if foo is a property or has __set__ defined on it. Doing all those checks each and every time the attribute is accessed has a performance penalty. This patch eliminates all those checks for cases when it's guaranteed that the checks will always fail, ie no attributes are properties nor have any special accessor methods defined on them. To make this guarantee it checks all attributes of a user-defined class when it is first created. If any of the attributes of the user class are properties or have special accessors, or any of the base classes of the user class have them, then it sets a flag in the class to indicate that special accessors must be checked for. Then in the load/store/delete code it checks this flag to see if it can take the shortcut and optimise the lookup. It's an optimisation that's pretty widely applicable because it improves lookup performance for all methods of user defined classes, and stores of attributes, at least for those that don't have special accessors. And, it allows to enable descriptors with minimal additional runtime overhead if they are not used for a particular user class. There is one restriction on dynamic class creation that has been introduced by this patch: a user-defined class cannot go from zero special accessors to one special accessor (or more) after that class has been subclassed. If the script attempts this an AttributeError is raised (see addition to tests/misc/non_compliant.py for an example of this case). The cost in code space bytes for the optimisation in this patch is: unix x64: +528 unix nanbox: +508 stm32: +192 cc3200: +200 esp8266: +332 esp32: +244 Performance tests that were done: - on unix x86-64, pystone improved by about 5% - on pyboard, pystone improved by about 6.5%, from 1683 up to 1794 - on pyboard, bm_chaos (from CPython benchmark suite) improved by about 5% - on esp32, pystone improved by about 30% (but there are caching effects) - on esp32, bm_chaos improved by about 11%
2018-04-10tests: Move recursive tests to the tests/stress/ subdir.Damien George
Keeping all the stress related tests in one place makes it easier to stress-test a given port, and to also not run such tests on ports that can't handle them.
2017-12-14tests: Add tests to improve coverage of py/objtype.c.Damien George
2017-10-03py/objset: Check that RHS of a binary op is a set/frozenset.Damien George
CPython docs explicitly state that the RHS of a set/frozenset binary op must be a set to prevent user errors. It also preserves commutativity of the ops, eg: "abc" & set() is a TypeError, and so should be set() & "abc". This change actually decreases unix (x64) code by 160 bytes; it increases stm32 by 4 bytes and esp8266 by 28 bytes (but previous patch already introduced a much large saving).
2017-06-10tests: Convert remaining "sys.exit()" to "raise SystemExit".Paul Sokolovsky
2017-03-11tests/misc/: Make few tests skippable.Paul Sokolovsky
2017-02-10tests/misc: Add test for line number printing with large bytecode chunk.Damien George
2017-01-19tests/misc/non_compliant: Add test for inability to assign func attrs.Damien George
2016-12-21tests: Add tests to improve coverage of objarray.c.Rami Ali
2016-10-17tests: Improve coverage of array, range, dict, slice, exc, unicode.Damien George
2016-10-11tests: Improve test coverage of py/compile.c.Damien George
2016-10-07tests: Improve coverage of struct with test for non-compliant behaviour.Damien George
2016-08-15tests/misc/non_compliant: Add tests to improve coverage testing.Damien George
2016-06-04tests/recursive_iternext: Clang/Linux is even more stack-frugal than MacOS.Paul Sokolovsky
2016-06-03tests/misc/recursive_iternext: Provide more fine-grained selection of N.Damien George
To work on a variety of ports the selection of N is very specific.
2016-06-03tests/misc/recursive_iternext.py: Increase depth N from 1000 to 2000.Damien George
This makes the test reliably overflow the recursion limit (which is the correct behaviour) on Mac OS X.
2016-05-02tests: Make "io" modules fixes for CPython compatibility.Paul Sokolovsky
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-02tests: Update for _io/_collections module having been renamed.Paul Sokolovsky
2016-03-07tests/recursive_iternext.py: Make low-heap friendly.Paul Sokolovsky
2016-03-07tests/print_exception: Use exception which prints the same regardless of config.Paul Sokolovsky
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-02-03py/mpz: Complete implementation of mpz_{and,or,xor} for negative args.Doug Currie
For these 3 bitwise operations there are now fast functions for positive-only arguments, and general functions for arbitrary sign arguments (the fast functions are the existing implementation). By default the fast functions are not used (to save space) and instead the general functions are used for all operations. Enable MICROPY_OPT_MPZ_BITWISE to use the fast functions for positive arguments.
2016-01-07py/parse: Improve constant folding to operate on small and big ints.Damien George
Constant folding in the parser can now operate on big ints, whatever their representation. This is now possible because the parser can create parse nodes holding arbitrary objects. For the case of small ints the folding is still efficient in RAM because the folded small int is stored inplace in the parse node. Adds 48 bytes to code size on Thumb2 architecture. Helps reduce heap usage because more constants can be computed at compile time, leading to a smaller parse tree, and most importantly means that the constants don't have to be computed at runtime (perhaps more than once). Parser will now be a little slower when folding due to calls to runtime to do the arithmetic.
2015-10-02tests: Allow tests to pass against CPython 3.5.Damien George
All breaking changes going from 3.4 to 3.5 are contained in basics/python34.py.
2015-10-01py/mpz: Raise NotImplError instead of failing assertion.Damien George
2015-09-07py/lexer: Raise NotImplError for unicode name escape, instead of assert.Damien George
2015-09-07tests: Add tests for non-compliant behaviour of lexer.Damien George
2015-09-04py/objstr: For str.endswith(s, start) raise NotImpl instead of assert.Damien George
2015-09-03tests: Add tests to improve coverage of objstr.c.Damien George
2015-09-01py/objstr: Make str.rsplit(None,n) raise NotImpl instead of assert(0).Damien George
2015-08-30tests: Fix non-compliant expected output to match actual behaviour.Damien George
2015-08-30tests: Add tests for non-compliant behaviour.Damien George
These tests are intended to improve coverage and provide a record of behaviour that's either not implemented or non-compliant to CPython.
2015-06-24tests: Adapt misc/features.py tests for ports without floating point.Daniel Campora
2015-06-03tests: Add test for recursive iternext stack overflow.Damien George
2015-04-26vm: On exiting except block, clear sys.exc_info() value.Paul Sokolovsky
This doesn't handle case fo enclosed except blocks, but once again, sys.exc_info() support is a workaround for software which uses it instead of properly catching exceptions via variable in except clause.
2015-04-25modsys: Add basic sys.exc_info() implementation.Paul Sokolovsky
The implementation is very basic and non-compliant and provided solely for CPython compatibility. The function itself is bad Python2 heritage, its usage is discouraged.