Skip to content

unittest.main fails to discover tests #414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
OpenBagTwo opened this issue Feb 17, 2021 · 4 comments
Closed

unittest.main fails to discover tests #414

OpenBagTwo opened this issue Feb 17, 2021 · 4 comments

Comments

@OpenBagTwo
Copy link

OpenBagTwo commented Feb 17, 2021

Running:

>>> import unittest
>>> unittest.main('my_package.tests.test_module')

results in

Ran 0 tests

OK

The workaround is to install test.support and utilize run_unittest but wow that's a lot of overhead.

The fix also appears to be to use the four-argument version of __import__:

Replace:

m = __import__(module)

with:

    m = __import__(module, None, ['object'], True)

Issue present with:

  • MicroPython
    • v1.14 on 2021-02-02; ESP module with ESP8266
    • 3d45bca-dirty on 2021-02-02; linux version
  • micropython-unittest
    • 0.3.2
@OpenBagTwo
Copy link
Author

Ah. Just discovered that this version of __import__ causes MemoryErrors on an ESP82xx boards (encountered using MicroPython v1.14 on 2021-02-02; ESP module (1M) with ESP8266). I'll go ahead and close this and figure out a better way to do unit test discovery.

@OpenBagTwo
Copy link
Author

Never mind. The issue was actually that my unit tests themselves exhausted the microcontroller's memory--I can't even directly import the test module. So the four-arg version of __import__ itself is not the problem.

@OpenBagTwo OpenBagTwo reopened this Apr 11, 2021
@mattytrentini
Copy link
Contributor

There has been some significant improvements in the unittest library recently - including around discovery. See #488 for details. Could you please update to the latest unittest library and try again?

@dpgeorge
Copy link
Member

dpgeorge commented Oct 4, 2022

This should be fixed now that #488 is merged.

@dpgeorge dpgeorge closed this as completed Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants