Found a workable solution:

Make the following change in "myapp/controllers/b.py":

============================================
if TEST_APP:
    import os
    import inspect
    import sys
    
    currentPath = os.path.dirname(os.path.abspath(
            inspect.getframeinfo(inspect.currentframe()).filename))
    modulePath = os.path.abspath(os.path.join(currentPath, '..', 'modules'))
    sys.path.append(modulePath)

import a
============================================

The explanation of TEST_APP can be found in 
http://packages.python.org/web2py_utils/test_runner.html

-ke

On Monday, July 2, 2012 1:24:53 PM UTC-7, Kemaru wrote:
>
> Folks,
>
> I have a module “myapp/modules/ a.py” and a controller 
> “myapp/controllers/b.py”. b imports a using “import a” and everything works 
> perfect.
>
> Now I am trying to run some unit tests using web2py_utils.test_runner (
> http://packages.python.org/web2py_utils/test_runner.html). All of a 
> sudden, I get the following error message:
>
> File "..\..\applications\myapp\controllers\b.py", line 14, in <module>
>
> ImportError: No module named a
>
> Has anyone used web2py_utils.test_runner and run into the same problem?
>
> Sorry if this is a duplicate question and thanks for your help in advance.
>
> -ke
>

Reply via email to