尝试在 Mac 上使用 Python TestRail API - ImportError : 没有名为 Conf_Re



我在Mac上收到以下导入错误:

ImportError: No module named Conf_Reader

以下是我的Python代码的几行初始行:

import dotenv
import os
import testrail
import Conf_Reader
#setup the testrail client and connect to the testrail instance
def get_testrail_client():
    testrail_file = os.path.join(os.path.dirname(__file__),'testrail.env')
    testrail_url = Conf_Reader.get_value(testrail_file,'TESTRAIL_URL')
    client = testrail.APIClient(testrail_url)
..
..
..

到目前为止,尝试使用pip,但找不到任何安装来源。

我在Mac上遇到了同样的问题。为避免使用其他独立性,您可以跳过使用 env。但作为变量传递:

# create a credential.py
TESTRAIL_URL='https://testrail.com/testrail'
TESTRAIL_USER='xxxxx'
TESTRAIL_PASSWORD = 'xxxxx'
# on your update_testrail.py
from credential import TESTRAIL_URL, 
TESTRAIL_USER, 
TESTRAIL_PASSWORD
testrail_url = TESTRAIL_URL
client = testrail.APIClient(testrail_url)
# Get and set the TestRail User and Password
client.user = TESTRAIL_USER
client.password = TESTRAIL_PASSWORD

他们应该链接到 https://bangladroid.wordpress.com/2016/08/20/create-separate-credential-files-for-selenium-python/

它解释你制作自己的"Conf_Reader.py"文件的地方如下:

"""
A simple conf reader.
For now, we just use dotenv and return a key.
"""
import dotenv,os
def get_value(conf,key):
    # type: (object, object) -> object
    "Return the value in conf for a given key"
    value = None
    try:
        dotenv.load_dotenv(conf)
        value = os.environ[key]
    except Exception,e:
        print 'Exception in get_value'
        print 'file: ',conf
        print 'key: ',key
    return value

相关内容

  • 没有找到相关文章

最新更新