Prior to this commit, if no tests were found when running unittest discover
then nothing at all was written to stdout, leading one to think it's not
working at all. CPython unittest does display a "0 tests run" sort of
output in such a case, and this commit ensures this package does the same.
This is not included by default in most builds, and isn't necessary for
this module anyway.
Also fix the local variable shadowing the traceback module in _capture_exc.
Added test for both (works on CPython and MicroPython).
Version bump to 0.10.2.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This allows a much more natural way of implementing unitttest-discover:
- unittest provides unittest/__init__.py
- unittest-discover provides unittest/__main__.py
It also fixes an bug where unittest.py previously detected the presence of
unittest-discover.py by importing an checking for the ImportError. But that
could also be raised by a missing dependency. Now when you run
`micropython -m unittest` without unittest-discover, you get
`ImportError: no module named 'unittest.__main__'`, and without the
required deps, `ImportError: no module named 'argparse'`.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The statement "with assertRaises(errtype) as ctxt" checks the type of a
raised exception, but did not store the exception into ctxt like unittest
of CPython. The exception instance is usually used to check its message or
other args.
In order to make this more suitable for non-unix ports, the discovery
functionality is moved to a separate 'extension' module which can be
optionally installed.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
With the dependencies captured in manifest.py, several packages in
python-stdlib were still unix-only due to direct or transitive dependencies
on unix-only or ffi modules. Or they just make no sense to run on
microcontroller targets.
In a few cases (e.g. base64) where possible, the unix dependency could be
removed.
Updates manifest.py to use the `unix_ffi=True` arg to `require()` for these
libraries.
Rename re-pcre to re now that unix-ffi is effectively its own namespace.
Update unix-ffi/README.md, and strengthen the wording that the unix
libraries are unmaintained.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Uses the new require()/package()/module() functions from manifestfile.py.
Add manifest.py for iperf3 and pyjwt.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Without this change, current implementaiton produces a false positive
result for AssertionError type.
Example of falsely passing test code:
def test(a, b):
assert a > 10
assert b > 10
self.assertRaises(AssertionError, test, 20, 20)