You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ImportError: Import by filename is not supported. #751
While running nose that uses python unittest builtin library.
Error log:
I/python: AND: Ran string
I/python: Run user program, change dir and execute entrypoint
I/Triblerd: Traceback (most recent call last):
I/Triblerd: File "Triblerd.py", line 33, in <module>
I/Triblerd: Triblerd().test()
I/Triblerd: File "Triblerd.py", line 29, in test
I/Triblerd: nose.run('-s ' + test_path)
I/Triblerd: File "/data/user/0/org.tribler.android/files/lib/python2.7/site-packages/nose/core.py", line 301, in run
I/Triblerd: return TestProgram(*arg, **kw).success
I/Triblerd: File "/data/user/0/org.tribler.android/files/lib/python2.7/site-packages/nose/core.py", line 121, in __init__
I/Triblerd: **extra_args)
I/Triblerd: File "/data/user/0/org.tribler.android/files/lib/python27.zip/unittest/main.py", line 77, in __init__
I/Triblerd: ImportError: Import by filename is not supported.
I/python: Python for android ended.
main.py source:
Actually, I don't think we're doing anything to break this. Using __import__ on a filename just isn't supported in general (at least in py2). On Ubuntu 16.04, Python 2.7.11:
In [1]: __import__('a/b/c.py')
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-61d17bad1646> in <module>()
----> 1 __import__('a/b/c.py')
ImportError: Import by filename is not supported.
Exactly. No fault of p4a at all! The issue was on python itself not supporting import by filename. I have worked around this.
Thanks a lot for your quick responses! I really appreciate it.
I will add a nose recipe soon, but before I can I have to figure out why the test module could be loaded but the test function inside it is not detected and nose ends with saying 0 tests executed.
Activity
inclement commentedon May 20, 2016
I wasn't aware of p4a doing anything that would break normal behaviour, though I could have forgotten about a patch doing that. Weird.
kived commentedon May 20, 2016
Actually, I don't think we're doing anything to break this. Using
__import__on a filename just isn't supported in general (at least in py2). On Ubuntu 16.04, Python 2.7.11:brussee commentedon May 20, 2016
Exactly. No fault of p4a at all! The issue was on python itself not supporting import by filename. I have worked around this.
Thanks a lot for your quick responses! I really appreciate it.
I will add a nose recipe soon, but before I can I have to figure out why the test module could be loaded but the test function inside it is not detected and nose ends with saying 0 tests executed.