Hello Fabio,
I have a problem running unit tests on a module in a package, when the name of the module is the same as a builtin.
(On WinXP, Eclipse 3.4.2, PyDev 1.4.7)
Example:
src
+- package
+- __init__.py
+- datetime.py
Where datetime contains at least one unit test.
Right-click on datetime.py, run as unit test:
Ran 0 tests in 0.000s
Renaming datetime.py to datetime2.py makes the test run.
I think the problem comes from the __importify method in PyDev's runfiles.py file.
It assumes that the file that contains unit tests is at the root of a PYTHONPATH.
I changed the end of the __importify method by changing the else to:
else: #handle dir
while os.path.exists(os.path.join(s, '__init__.py')):
s, _ = os.path.split(s)
return s.replace("\\", "/").replace("/", ".")
Issues:
- Will it work on Python 3 with no __init__.py files ? (I only use this Python 2.6 yet)
- This only checks for .py files (what about .pyc files ?)
- Not sure about side effects (Did not run the full pydev tests)
Cheers,
Laurent.
Sample project