summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2020-10-10update async tests with less upython workaround and more cpython compatibilityKenny
2020-09-12modstruct: Improve compliance with python3Jeff Epler
While checking whether we can enable -Wimplicit-fallthrough, I encountered a diagnostic in mp_binary_set_val_array_from_int which led to discovering the following bug: ``` >>> struct.pack("xb", 3) b'\x03\x03' ``` That is, the next value (3) was used as the value of a padding byte, while standard Python always fills "x" bytes with zeros. I initially thought this had to do with the unintentional fallthrough, but it doesn't. Instead, this code would relate to an array.array with a typecode of padding ('x'), which is ALSO not desktop Python compliant: ``` >>> array.array('x', (1, 2, 3)) array('x', [1, 0, 0]) ``` Possibly this is dead code that used to be shared between struct-setting and array-setting, but it no longer is. I also discovered that the argument list length for struct.pack and struct.pack_into were not checked, and that the length of binary data passed to array.array was not checked to be a multiple of the element size. I have corrected all of these to conform more closely to standard Python and revised some tests where necessary. Some tests for micropython-specific behavior that does not conform to standard Python and is not present in CircuitPython was deleted outright.
2020-09-07update expected result with new methodJeff Epler
2020-09-06core: add int.bit_length() when MICROPY_CYPTHON_COMPAT is enabledJeff Epler
This method of integer objects is needed for a port of python3's decimal.py module. MICROPY_CPYTHON_COMPAT is enabled by CIRCUITPY_FULL_BUILD.
2020-07-24py/compile: Don't await __aiter__ special method in async-for.Jonathan Hogg
MicroPython's original implementation of __aiter__ was correct for an earlier (provisional) version of PEP492 (CPython 3.5), where __aiter__ was an async-def function. But that changed in the final version of PEP492 (in CPython 3.5.2) where the function was changed to a normal one. See https://www.python.org/dev/peps/pep-0492/#why-aiter-does-not-return-an-awaitable See also the note at the end of this subsection in the docs: https://docs.python.org/3.5/reference/datamodel.html#asynchronous-iterators And for completeness the BPO: https://bugs.python.org/issue27243 To be consistent with the Python spec as it stands today (and now that PEP492 is final) this commit changes MicroPython's behaviour to match CPython: __aiter__ should return an async-iterable object, but is not itself awaitable. The relevant tests are updated to match. See #6267.
2020-07-23also disable async_coroutine test in native emitterKenny
2020-07-23add coroutine behavior for generatorsKenny
coroutines don't have __next__; they also call themselves coroutines. This does not change the fact that `async def` methods are generators, but it does make them behave more like CPython.
2020-07-16Merge pull request #3143 from tannewt/improve_jsonDan Halbert
Add support to json.load for any object with readinto
2020-07-10Fix stream version and add basic readinto testScott Shawcroft
2020-07-06Add license to some obvious files.Diego Elio Pettenò
2020-06-25README: Remove a statement that's not particularly true at the momentJeff Epler
2020-06-25tests: Remove a test for micropython-specific SPI behaviorJeff Epler
2020-06-25Scripts: Change wording for pseudoterminalsJeff Epler
2020-06-03Fix up end of file and trailing whitespace.Diego Elio Pettenò
This can be enforced by pre-commit, but correct it separately to make it easier to review.
2020-04-13test requires yield, can't run nativeJeff Epler
2020-04-01tests: Add .exp files for basics/parser and import/import_override.Damien George
Because CPython 3.8.0 now produces different output: - basics/parser.py: CPython does not allow '\\\n' as input. - import/import_override: CPython imports _io.
2020-03-31tests/basics: Provide .exp files for generator tests that fail PEP479.Damien George
PEP479 (see https://www.python.org/dev/peps/pep-0479/) prohibited raising StopIteration from within a generator (it is turned into a RuntimeError). This behaviour was introduced in Python 3.5 and in 3.7 was made compulsory. Until uPy implements PEP479, this patch adds .py.exp files for the relevant tests so they can be run under Python 3.7.
2020-03-31tests: 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.
2020-03-31tests/basics/int_big_error.py: Use bytearray to test for int overflow.Damien George
In Python 3.7 "1 >> (big int)" is now allowed, it no longer raises an OverflowError. So use bytearray to test big-int conversion overflow.
2020-03-31tests/basics/set_pop.py: Sort set before printing for consistent output.Damien George
2020-03-09Update testsJeff Epler
* string_pep498_fstring.py: Not compatible with python3.5 * cmd_parsetree.py: enumerated constants changed
2020-03-09lexer: catch concatenation of f'' and '' stringsJeff Epler
This turns the "edge case" into a parse-time error.
2020-03-09Address dpgeorge feedback - largely simplificationsJosh Klar
2020-03-09py: Implement partial PEP-498 (f-string) supportJosh Klar
This implements (most of) the PEP-498 spec for f-strings, with two exceptions: - raw f-strings (`fr` or `rf` prefixes) raise `NotImplementedError` - one special corner case does not function as specified in the PEP (more on that in a moment) This is implemented in the core as a syntax translation, brute-forcing all f-strings to run through `String.format`. For example, the statement `x='world'; print(f'hello {x}')` gets translated *at a syntax level* (injected into the lexer) to `x='world'; print('hello {}'.format(x))`. While this may lead to weird column results in tracebacks, it seemed like the fastest, most efficient, and *likely* most RAM-friendly option, despite being implemented under the hood with a completely separate `vstr_t`. Since [string concatenation of adjacent literals is implemented in the lexer](https://github.com/micropython/micropython/commit/534b7c368dc2af7720f3aaed0c936ef46d773957), two side effects emerge: - All strings with at least one f-string portion are concatenated into a single literal which *must* be run through `String.format()` wholesale, and: - Concatenation of a raw string with interpolation characters with an f-string will cause `IndexError`/`KeyError`, which is both different from CPython *and* different from the corner case mentioned in the PEP (which gave an example of the following:) ```python x = 10 y = 'hi' assert ('a' 'b' f'{x}' '{c}' f'str<{y:^4}>' 'd' 'e') == 'ab10{c}str< hi >de' ``` The above-linked commit detailed a pretty solid case for leaving string concatenation in the lexer rather than putting it in the parser, and undoing that decision would likely be disproportionately costly on resources for the sake of a probably-low-impact corner case. An alternative to become complaint with this corner case of the PEP would be to revert to string concatenation in the parser *only when an f-string is part of concatenation*, though I've done no investigation on the difficulty or costs of doing this. A decent set of tests is included. I've manually tested this on the `unix` port on Linux and on a Feather M4 Express (`atmel-samd`) and things seem sane.
2020-03-03Use tests from ulab extmod, instead of our ownJeff Epler
2020-02-27Update ulab from upstream againJeff Epler
2020-02-27ulab: Incorporate itJeff Epler
2020-02-14Implement to_bytes(..., signed=True)Dan Halbert
2020-01-09Add test for issue #2465 - tuple subsclass subscriptRoy Hooper
2019-10-14Support __bytesScott Shawcroft
Fixes #1763
2019-06-26Fix testsScott Shawcroft
2019-05-12use approx of original @godlygeek code for smallints; add testsDan Halbert
2019-05-09Add tests for overflows converting ints to bytesMatt Wozniski
2019-05-07Fix tests and clarify first character accessKathryn Lingel
2019-05-06Correct output expectationKathryn Lingel
2019-05-06Update tests for new autocomplete behaviorKathryn Lingel
2019-02-14extmod/ure: Handle some escape sequences.Radomir Dopieralski
Fix MicroPython #3176 Handle escape sequences inside regular expressions. This adds handling for \a, \b, \f, \n, \r, \v and \\.
2019-02-14extmod/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.
2019-02-14extmod/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.
2019-02-14extmod/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-08-25Fix os.stat() to use 1970 epochNoralf Trønnes
Commit 95e70cd0ea6d 'time: Use 1970 epoch' changed epoch for the time module, but not for other users. This patch does the same for the only other core timeutils user: extmod/vfs_fat.c:fat_vfs_stat(). Other timeutils users: cc3200, esp8266 and stm32, are not changed. Ports that don't use long ints, will still get wrong time values from os.stat().
2018-07-28merge finishedDan Halbert
2018-07-11WIP: after merge; before testingDan Halbert
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-14Make Trinket M0 build fit; make RAMFS in vfs_fat_* tests be compliant with ↵Dan Halbert
expected API
2018-06-12tests/extmod: Add test for VFS and user-defined filesystem and files.Damien George