我正在尝试导入当前目录中的文件,但我得到类似这样的内容
module_not_in_the_pythonpath__
我在该文件中定义的所有变量。
我添加了路径
C:/Project/main_test_folder
在python-path
中我的目录结构是这样的。
main_test_folder
test_folder1 //working fine here
__init__.py
Constants.py
Some test file Constant.py will be imported.
test_folder2 //working fine here
__init__.py
Constants.py
//Some test file Constant.py will be imported.
test_folder3 //for this folder alone its not working
__init__.py
Constants.py
Common.py //Constant.py is imported in this(not working)
Testcase.py
//Some more test file ,Constant.py,Common.py will be imported in each file.
Common.py
from constants import *
class Payload(object):
def __init__(self, params):
'''
Constructor
'''
@staticmethod
def createPayLoad(Name,model): //NAME and MODEL Defined in constants.py
PAYLOAD_PROFILE={
NAME: Name,
MODEL: model,
}
return PAYLOAD
Testcase.py
from common import * //this line is not working
from constants import *
错误:
test_folder3\test_01_rename.py:15: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @staticmethod def
createPayLoad(Name, model): PAYLOAD={ > NAME: Name,MODEL: model} E NameError: global
name 'NAME' is not defined test_folder3\common .py:34: NameError</failure>