aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2018-07-02extmod/modure: Add ure.sub() function and method, and tests.Damien George
This feature is controlled at compile time by MICROPY_PY_URE_SUB, disabled by default. Thanks to @dmazzella for the original patch for this feature; see #3770.
2018-07-02extmod/modure: Add match.span(), start() and end() methods, and tests.Damien George
This feature is controlled at compile time by MICROPY_PY_URE_MATCH_SPAN_START_END, disabled by default. Thanks to @dmazzella for the original patch for this feature; see #3770.
2018-07-02extmod/modure: Add match.groups() method, and tests.Damien George
This feature is controlled at compile time by MICROPY_PY_URE_MATCH_GROUPS, disabled by default. Thanks to @dmazzella for the original patch for this feature; see #3770.
2018-06-27py/compile: Handle return/break/continue correctly in async with.Damien George
Before this patch the context manager's __aexit__() method would not be executed if a return/break/continue statement was used to exit an async with block. async with now has the same semantics as normal with. The fix here applies purely to the compiler, and does not modify the runtime at all. It might (eventually) be better to define new bytecode(s) to handle async with (and maybe other async constructs) in a cleaner, more efficient way. One minor drawback with addressing this issue purely in the compiler is that it wasn't possible to get 100% CPython semantics. The thing that is different here to CPython is that the __aexit__ method is not looked up in the context manager until it is needed, which is after the body of the async with statement has executed. So if a context manager doesn't have __aexit__ then CPython raises an exception before the async with is executed, whereas uPy will raise it after it is executed. Note that __aenter__ is looked up at the beginning in uPy because it needs to be called straightaway, so if the context manager isn't a context manager then it'll still raise an exception at the same location as CPython. The only difference is if the context manager has the __aenter__ method but not the __aexit__ method, then in that case uPy has different behaviour. But this is a very minor, and acceptable, difference.
2018-06-27tests: Move non-filesystem io tests to basics dir with io_ prefix.Damien George
2018-06-27tests/basics/namedtuple*: Import ucollections first.Paul Sokolovsky
Otherwise, test may have artefacts in the presence of the micropython-lib module.
2018-06-27tests/extmod/ucryptolib*: Add into and inplace tests for ucryptolib.Paul Sokolovsky
Tests for separate input and output buffer (alloc-free operation) and the same writable buffer used as input and output (inplace operation).
2018-06-27tests/extmod/ucryptolib*: Add tests for ucryptolib module.Paul Sokolovsky
2018-06-20tests: Add tests using "file" argument in print and sys.print_exception.Damien George
2018-06-18tests/import: Add test for importing invalid .mpy file.Damien George
2018-06-18tests/extmod: Add test for ujson.dump writing to a user IOBase object.Damien George
2018-06-18tests/extmod/ujson_dump.py: Add test for dump to non-stream object.Damien George
2018-06-18tests/unix/extra_coverage: Don't test stream objs with NULL write fun.Damien George
This behaviour of a NULL write C method on a stream that uses the write adaptor objects is no longer supported. It was only ever used by the coverage build for testing the fail path of mp_get_stream_raise().
2018-06-12tests/extmod: Add test for VFS and user-defined filesystem and files.Damien George
2018-06-12tests/io: Add simple IOBase test.Damien George
2018-06-12py/lexer: Add support for underscores in numeric literals.Damien George
This is a very convenient feature introduced in Python 3.6 by PEP 515.
2018-06-08tests/pyb: Make i2c and pyb1 pyboard tests run again.Damien George
For i2c.py: the accelerometer now uses the new I2C driver so need to explicitly init the legacy i2c object to get the test working. For pyb1.py: the legacy pyb.hid() call will crash if the USB_HID object is not initialised.
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-06-06tests/extmod: Remove conditional import of uos_vfs, it no longer exists.Damien George
This conditional import was only used to get the tests working on the unix coverage build, which has now switched to use VFS by default so the uos module alone has the required functionality.
2018-06-06tests/extmod: Add test for importing a script from a user VFS.Damien George
2018-05-30py/objtype: Fix assertion failures in super_attr by checking type.Jeff Epler
Fixes assertion failures and segmentation faults when making calls like: super(1, 1).x
2018-05-30py/objtype: Fix assertion failures in mp_obj_new_type by checking types.Jeff Epler
Fixes assertion failures when the arguments to type() were not of valid types, e.g., when making calls like: type("", (), 3) type("", 3, {})
2018-05-25py/objtype: Remove TODO comment about needing to check for property.Damien George
Instance members are always treated as values, even if they are properties. A test is added to show this is the case.
2018-05-23py/emit: Combine yield value and yield-from emit funcs into one.Damien George
Reduces code size by: bare-arm: -24 minimal x86: -72 unix x64: -200 unix nanbox: -72 stm32: -52 cc3200: -32 esp8266: -84 esp32: -24
2018-05-22py/objgenerator: Protect against reentering a generator.Damien George
Generators that are already executing cannot be reexecuted. This patch puts in a check for such a case. Thanks to @jepler for finding the bug.
2018-05-22py/modbuiltins: Add support for rounding integers.Jan Klusacek
As per CPython semantics. This feature is controlled by MICROPY_PY_BUILTINS_ROUND_INT which is disabled by default.
2018-05-21tests: Add some tests for bigint hash, float hash and float parsing.Damien George
Following outcome of recent fuzz testing and sanitizing by @jepler.
2018-05-11tests/basics/special_methods2: Enable some additional tests that work.Damien George
These special methods are all available if MICROPY_PY_ALL_SPECIAL_METHODS is enabled.
2018-05-11tests/float/float_parse: Allow test to run on 32-bit archs.Damien George
Printing of uPy floats can differ by the floating-point precision on different architectures (eg 64-bit vs 32-bit x86), so it's not possible to using printing of floats in some parts of this test. Instead we can just check for equivalence with what is known to be the correct answer.
2018-05-10py/modbuiltins: Make built-in dir support the __dir__ special method.Damien George
If MICROPY_PY_ALL_SPECIAL_METHODS is enabled then dir() will now delegate to the special method __dir__ if the object it is listing has this method.
2018-05-10py/modbuiltins: Make built-in hasattr work properly for user types.Damien George
It now allows __getattr__ in a user type to raise AttributeError when the attribute does not exist.
2018-05-08tests/cpydiff: Remove types_int_tobytesfloat now that it doesn't fail.Damien George
Commit e269cabe3ed8bed1b7181359febb686edbb748ae added a check that the first argument to the to_bytes() method is an integer, and now uPy follows CPython behaviour and raises a TypeError for this test. Note: CPython checks the argument types before checking the number of arguments, but uPy does it the other way around, so they give different exception messages for this test, but still the same type, a TypeError.
2018-05-04tests/cpydiff: Remove working cases from types_float_rounding.Damien George
2018-05-04tests/cpydiff: Remove types_str_decodeerror now that it succeeds.Damien George
Commit 68c28174d0e0ec3f6b1461aea3a0b6a1b84610bb implemented checking for valid utf-8 data.
2018-05-04tests/cpydiff: Remove core_function_unpacking now that it succeeds.Damien George
Commit 1e70fda69fcb4991eb60ed43e610f664ea1319e6 fixes this difference.
2018-05-02tests/run-tests: Support esp32 as a target for running the test suite.Ayke van Laethem
2018-05-02tests/pyb: Update tests to run correctly on PYBv1.0.Damien George
In adcall.py the pyb module may not be imported, so use ADCAll directly. In dac.py the DAC object now prints more info, so update .exp file. In spi.py the SPI should be deinitialised upon exit, so the test can run a second time correctly.
2018-05-01tests/io/bytesio_ext2: Remove dependency on specific EINVAL valueMike Wadsten
If MICROPY_USE_INTERNAL_ERRNO is disabled, MP_EINVAL is not guaranteed to have the value 22, so we cannot depend on OSError(22,). Instead, to support any given port's errno values, without relying on uerrno, we just check that the args[0] is positive.
2018-04-11tests/pyb: Add test for pyb.ADCAll class.Damien George
2018-04-11stm32/dac: Add buffering argument to constructor and init() method.Damien George
This can be used to select the output buffer behaviour of the DAC. The default values are chosen to retain backwards compatibility with existing behaviour. Thanks to @peterhinch for the initial idea to add this feature.
2018-04-11stm32/adc: Add read_timed_multi() static method, with docs and tests.Peter Hinch
2018-04-11tests/pyb/adc.py: Fix test so that it really does test ADC values.Damien George
Reading into a bytearray will truncate values to 0xff so the assertions checking read_timed() would previously always succeed. Thanks to @peterhinch for finding this problem and providing the solution.
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.
2018-04-10tests/stress/recursive_gen: Add test for recursive gen with iter.Damien George
2018-04-10py/objgenerator: Check stack before resuming a generator.Jeff Epler
This turns a hard crash in a recursive generator into a 'maximum recursion depth exceeded' exception.
2018-04-05py/objstr: In find/rfind, don't crash when end < start.Jeff Epler
2018-04-05tests/micropython/extreme_exc.py: Allow to run without any emg exc buf.Damien George
2018-04-05tests/micropython/extreme_exc.py: Fix test to run on more ports/configs.Damien George
2018-04-05tests/micropython: Add set of tests for extreme cases of raising exc's.Damien George
2018-04-05tests/basics/string_compare.py: Add test with string that hashes to 0.Damien George
The string "Q+?" is special in that it hashes to zero with the djb2 algorithm (among other strings), and a zero hash should be incremented to a hash of 1.