[issue24263] unittest cannot load module whose name starts with Unicode

Toshio Kuratomi report at bugs.python.org
Fri May 10 12:59:09 EDT 2019


Toshio Kuratomi <a.badger at gmail.com> added the comment:

>From the description, I think the bug is that filenames that *begin* with non-ascii are not searched for tests.  Looking at the test_dir.tar.gz contents,  this is the test case that I'd use:

Broken:

$ python3 -m unittest discover -vv -p '*.py'
test_走 (tests試驗.Test試驗.試驗) ... ok
test_走 (tests試驗.test試驗.試驗) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.000s

OK

Corrected:
$ /srv/python/cpython/python -m unittest discover -vv -p '*.py'
test_走 (tests試驗.Test試驗.試驗) ... ok
test_走 (tests試驗.test試驗.試驗) ... ok
test_走 (tests試驗.試驗.試驗) ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.000s

OK


isidentifier() is used because filenames to be discovered must be importable and thus valid identifiers:  https://docs.python.org/3/library/unittest.html#test-discovery

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue24263>
_______________________________________


More information about the Python-bugs-list mailing list