Python change path inside submodule? -



Python change path inside submodule? -

i have project structure:

- main.py - app_a/ - __init__.py - app.py - stubs/ - app.py - tests/ - test_app_a.py

in main.py, there is:

from app_a.app import foo

this works fine. however, when running in test environment(which can checked env variable), need main.py import stub module (which in app_a/stubs/app.py) instead of real app_a/app.py.

notice can't alter main.py itself, can alter environment before runs.

how can implement this? thanks.

why not write follows in main.py

if env: app_a.app import foo else: app_a.stubs.app import foo

python

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -