I believe thatIf you need to fix 2 thingsfollow the structure of this guide here:http://docs.python-guide.org/en/latest/writing/structure/#test-suite (highly recommend reading it all, it is very helpful) you will see this:
- Add a
__init__.pyfile in the job folder so as to be recognized as a module by itself (which enables it's ability to import other modules in it) - Do not name your "root" folder '.' but give it a name (ex root_folder). Then call the module as:
from root_folder.modules.print_module import do_stuff
To give the individual tests import context, create a tests/context.py file:
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import sample
Then, within the individual test modules, import the module like so:
from .context import sample
This will always work as expected, regardless of installation method.
Translated in your case this means:
root_folder
├── job
│ ├── context.py <- create this file
│ └── the_script.py
└── modules
├── __init__.py
└── print_module.py
In the context.py file write the lines shown above, but import modules instead of import samples
Finally in your the_script.py: from .context import module and you will be set to go!
Good luck :)
I believe that you need to fix 2 things:
- Add a
__init__.pyfile in the job folder so as to be recognized as a module by itself (which enables it's ability to import other modules in it) - Do not name your "root" folder '.' but give it a name (ex root_folder). Then call the module as:
from root_folder.modules.print_module import do_stuff
Good luck :)
If you follow the structure of this guide here:http://docs.python-guide.org/en/latest/writing/structure/#test-suite (highly recommend reading it all, it is very helpful) you will see this:
To give the individual tests import context, create a tests/context.py file:
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import sample
Then, within the individual test modules, import the module like so:
from .context import sample
This will always work as expected, regardless of installation method.
Translated in your case this means:
root_folder
├── job
│ ├── context.py <- create this file
│ └── the_script.py
└── modules
├── __init__.py
└── print_module.py
In the context.py file write the lines shown above, but import modules instead of import samples
Finally in your the_script.py: from .context import module and you will be set to go!
Good luck :)
I believe that you need to fix 2 things:
- Add a
__init__.pyfile in the job folder so as to be recognized as a module by itself (which enables it's ability to import other modules in it) - Do not name your "root" folder '.' but give it a name (ex root_folder). Then call the module as:
from root_folder.modules.print_module import print_moduledo_stuff
Good luck :)
I believe that you need to fix 2 things:
- Add a
__init__.pyfile in the job folder so as to be recognized as a module by itself (which enables it's ability to import other modules in it) - Do not name your "root" folder '.' but give it a name (ex root_folder). Then call the module as:
from root_folder.modules import print_module
Good luck :)
I believe that you need to fix 2 things:
- Add a
__init__.pyfile in the job folder so as to be recognized as a module by itself (which enables it's ability to import other modules in it) - Do not name your "root" folder '.' but give it a name (ex root_folder). Then call the module as:
from root_folder.modules.print_module import do_stuff
Good luck :)
I believe that you need to fix 2 things:
- Add a
__init__.pyfile in the job folder so as to be recognized as a module by itself (which enables it's ability to import other modules in it) - Do not name your "root" folder '.' but give it a name (ex root_folder). Then call the module as:
from root_folder.modules import print_module
Good luck :)