summaryrefslogtreecommitdiff
path: root/tests/io
AgeCommit message (Collapse)Author
2024-03-07all: Prune trailing whitespace.Phil Howard
Prune trailing whitespace across the whole project (almost), done automatically with: grep -IUrl --color "[[:blank:]]$" --exclude-dir=.git --exclude=*.exp |\ xargs sed -i 's/[[:space:]]*$//' Exceptions: - Skip third-party code in lib/ and drivers/cc3100/ - Skip generated code in bluetooth_init_cc2564C_1.5.c - Preserve command output whitespace in docs, eg: docs/esp8266/tutorial/repl.rst Signed-off-by: Phil Howard <phil@gadgetoid.com>
2023-09-01extmod/vfs_posix_file: Implement sys.std*.buffer objects.stephanelsmith
Add the buffer attribute to sys.stdin, sys.stdout and sys.stderr. This provides raw access to underlying stdio streams for the unix port (and others that use VfsPosix). Signed-off-by: stephanelsmith <stephane.smith@titansensor.com>
2023-06-08tests: Replace umodule with module everywhere.Jim Mussared
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-05-18tests/run-tests.py: Ensure correct cwd for mpy tests.Jim Mussared
Previously when using --via-mpy, the file was compiled to tests/<tmp>.mpy and then run using `micropython -m <tmp>` in the current cwd (usually tests/). This meant that an import in the test would be resolved relative to tests/. This is different to regular (non-via-mpy) tests, where we run (for example) `micropython basics/test.py` which means that an import would be resolved relative to basics/. Now --via-mpy matches the .py behavior. This is important because: a) It makes it so import tests do the right thing. b) There are directory names in tests/ that match built-in module names. Furthermore, it always ensures the cwd (for both micropython and cpython) is the test directory (e.g. basics/) rather than being left unset. This also makes it clearer inside the test that e.g. file access is relative to the Python file. Updated tests with file paths to match. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-12-17py/modio: Remove io.resource_stream function.Jim Mussared
This feature is not enabled on any port, it's not in CPython's io module, and functionality is better suited to the micropython-lib implementation of pkg_resources.
2021-02-11extmod/vfs_posix_file: Allow closing an already closed file.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.
2018-11-26tests/io: Update tests to use uos.remove() instead of uos.unlink().Paul Sokolovsky
After Unix port switches from one to another, to be consistent with baremetal ports.
2018-06-27tests: Move non-filesystem io tests to basics dir with io_ prefix.Damien George
2018-06-20tests: Add tests using "file" argument in print and sys.print_exception.Damien George
2018-06-12tests/io: Add simple IOBase test.Damien George
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.
2017-08-20py/stream: seek: Consistently handle negative offset for SEEK_SET.Paul Sokolovsky
Per POSIX, this is EINVAL, so raises OSError(EINVAL).
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-06-10tests: Convert remaining "sys.exit()" to "raise SystemExit".Paul Sokolovsky
2017-06-09py/objstringio: If created from immutable object, follow copy on write policy.Paul Sokolovsky
Don't create copy of immutable object's contents until .write() is called on BytesIO.
2017-05-15tests/io/bytesio_ext: Test read() after seek() past end of BytesIO object.Tom Collins
2017-05-06py/modio: resource_stream: Implement "package" param handling.Paul Sokolovsky
2017-05-03tests/io/resource_stream: Add test for uio.resource_stream().Paul Sokolovsky
2017-01-17tests/io: Improve test coverage of io.BufferedWriter.Rami Ali
2016-11-14tests: Use read() instead of readall().Paul Sokolovsky
2016-10-09tests/io/bytesio_ext: Add test for readinto().Paul Sokolovsky
2016-10-09tests/io/write_ext: Add description comment.Paul Sokolovsky
2016-07-29tests/io/bytesio_ext: Test for .seek()/.flush() on BytesIO.Paul Sokolovsky
2016-07-14tests: Add test for extended arguments to stream .write() method.Paul Sokolovsky
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-25tests: Add test for io.BufferedWriter.Paul Sokolovsky
2016-03-17tests/io: Remove "testfile" at end of open_plus test.Damien George
2016-02-06tests/open_plus: Add tests for "r+", "w+" open modes.Paul Sokolovsky
2015-12-23tests: Add tests for stream IO errors.Damien George
2015-12-12unix: Rename "_os" module to "uos" for consistency with baremetal ports.Paul Sokolovsky
2015-08-21tests: Make io test cleanup after itself by removing 'testfile'.Damien George
2015-08-13py: Add stream_tell method, and use for unix and stmhal file tell.blmorris
2015-06-21tests: Add testcase for open(..., "a").Paul Sokolovsky
2015-04-04tests: Add missing tests for builtins, and many other things.Damien George
2015-01-29tests: Add some tests to improve coverage.Damien George
2015-01-23tests: Fix typo in file_long_read3.py.Paul Sokolovsky
2015-01-23tests: Add extra test for reading multiple of internal chunk size.Paul Sokolovsky
2015-01-23tests: Add testcase for reading amounts bigger than buffer/chunk size.Paul Sokolovsky
2015-01-20py: Prevent segfault for operations on closed StringIO.stijn
Addresses issue #1067.
2014-11-16py: Make stream seek correctly check for ioctl fn; add seek for textio.Damien George
2014-11-17tests: Add test for file.seek().Paul Sokolovsky
2014-10-23stream: Add optional 2nd "length" arg to .readinto() - extension to CPython.Paul Sokolovsky
While extension to file.readinto() definition of CPython, the additional arg is similar to what in CPython available in socket.recv_into().
2014-10-21Use mode/encoding kwargs in io and unicode testsstijn
mode argument is used to assert it works encoding argument is used to make sure CPython uses the correct encoding as it does not automatically use utf-8
2014-10-18unix, stmhal: Implement file.readinto() method.Paul Sokolovsky
Also, usocket.readinto(). Known issue is that .readinto() should be available only for binary files, but micropython uses single method table for both binary and text files.
2014-07-22tests: Add testcase for read by length past EOF.Paul Sokolovsky
Currently broken for unicode input streams.
2014-07-05tests: Rename test scripts, changing - to _ for consistency.Damien George
From now on, all new tests must use underscore. Addresses issue #727.
2014-06-12py: Rename builtin "io" to "_io".Paul Sokolovsky
Functionality we provide in builtin io module is fairly minimal. Some code, including CPython stdlib, depends on more functionality. So, there's a choice to either implement it in C, or move it _io, and let implement other functionality in Python. 2nd choice is pursued. This setup matches CPython too (_io is builtin, io is Python-level).